Importing CSV with First Record as Field Names


#1

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


#2

Yes. You can use code like this:

FirstRecord
Loop Left until stopped
Loop fieldname «» right until stopped

and then delete the first record.


#3

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 «»
endloop
deleterecord

#4

Both work great, thanks!