Import via Creat New

If I open a .csv file using this method…

File/New/New Database from Text File...

all is good.

If I use this method to import the same .csv into a database created by the above,

File/Import/Import Text File into Current Database...   (Skip First Line)

the new records get parsed with some records being imported into many records. I believe they probably have Tabs, Returns, or such in the .csv.

Shouldn’t both methods work identically?

1 Like

When you do this, Panorama actually creates a new database, then imports the text into it. Here’s the actual code:

Notice lines 40 and 42.

When you import using the Text Import wizard, the importtext statement is also used, exactly the same. However, there will also be a rearrange parameter added, which will depend on how you’ve set up the input template. But that shouldn’t affect whether records have tabs or returns in them.

If the CSV file is really “the same”, then you’ll get the same results. It’s the same code either way. If you can really get different results by importing a single file twice, with no changes to the file, I’d really like to see a copy of that CSV file. I don’t think that is possible. If you think you do have such an example and want to send me the file, I would also need to have the exact configuration you used for the Import Wizard field arrangement.

Robert sent me the file, and the mystery is solved. His CSV file is comma delimited, but some of the cells contain tab characters, including cells in the first data record.

Panorama uses the first line of data in the file to determine what the field separator is. When creating a new database, it looks a the first line which contains the field names. In his database, this line contains only commas, no tabs, so everything works. But when importing into an existing database, it skips the line with the field names, and using the second line of data it decides that the data is tab separated. That’s wrong, so the data doesn’t import correctly.

As it turns out, the CSV file really wasn’t the same. When importing into an existing database, the first line (containing the field names) is stripped off, so it’s really a different CSV file. So it got different results.

I was able to successfully import Robert’s file with a one line program that explicitly specified that the import should be comma separated.

importtext arrayrange(lftocr(fileload(“path/some.csv”)),2,-1,cr()),“Separator”,“,”

In general, I would recommend that you avoid tabs in comma separated data whenever possible.

It is very common that a user receives a .csv file from an external source. The user has no control over how the contents or format of the file. If the New Database from a Text File can successfully import a file with tabs in the data, it would be great if the Import of that same file accomplished the same result as the user did choose to ‘Skip First Line’. The result did not meet the expectation.