Importing CSV with First Record as Field Names

Greetings, new here, so this may have already been covered. I’m opening CSV files in Panorama X with the first record being the field names. Is there a way to get the fields names automatically populated from the first record? Thanks

Yes. You can use code like this:

Loop Left until stopped
Loop fieldname «» right until stopped

and then delete the first record.

1 Like

Here is a procedure you could run from another database that would both open the CSV file, and rename the fields. It uses a couple of features that are new to Panorama X.

Local folder, file, type
openfiledialog folder, file, type, "TEXT"
if file = "" stop endif
openfile folderpath(folder)+file
for x, 1, info("fieldcount")
    field x+0
    fieldname «»

Both work great, thanks!

Thanks KJM. This has been a big wish for me since I started using Panorama. I just imported a huge property sales database with 120 fields. Your procedure saved me hours.

And another new statement is FirstColumn. This elminates the need for the Loop Left.

It’s 2020 – there is no need for a custom procedure, this feature is now built into Panorama. Just choose File>New>New Database From Text File and everything will be taken care of. This is described in New Database From Text File on this page.

Though you don’t need to write a program for this any more, if you did want to for some other reason there is now a statement that sets all of the field names at once, without a loop (in fact, this is what Panorama uses when you create a new database from a text file).