Jump to content
Server Maintenance This Week. ×

CSV import problem


This topic is 715 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi.

I have a CSV file that has dozens of lines that look much like this:

"first field a" ; "second field a" ; "third field a" ; 17 ;
"first field b" ; "second field b" ; "third field b" ; 26 ;

I have read this into a variable ($csvData) with the Files.ReadFile command - which seems to have worked OK.
I then want to import these entries into a table with the FM.InsertRecordCSV command, but it is giving me grief.

MBS("FM.InsertRecordCSV" ; "Solution.fmp12" ; "Part_List" ; "Product_Code¶Description¶Brand¶SOH" ; Char(59) ; $csvData)

It reports the following:  "[MBS] CSV has 2 columns, but we have 4 field names"
It seems to have seen the four field names OK. The first three are text fields, the last is a number - in case this makes a difference.

Given that Char(59) is the semicolon, and I have also put the semicolon in quotes there instead as a test, why does MBS see only 2 columns in that data?
(Oddly enough, as a test, I replaced the semicolons with a pipe symbol (Char(124)) and then it reported that the CSV only had one column. That confused me even more.)
I get the same result if I use the data directly from the CSV file in a container as opposed to a variable.

Can anybody suggest please what I may be doing wrong here?

Many thanks in advance,
Greg

 

Link to comment
Share on other sites

Your CSV is really with spaces after the quote? that seems strange to me.

 

And I think you swapped parameters: Char(59) ; $csvData

 

MBS( "FM.InsertRecordCSV"; InsertFileName; InsertTableName; FieldNames; Text { ; Delimiter; FieldName...; FieldValue... } )

 

Link to comment
Share on other sites

Hi Comment.

Thanks for your reply. 

The error was mine and I have resolved it.  The native one works for me as well now.

Thankyou.
Greg

Hi Christian,

Duh.  Indeed, I had the delimiter and the data back to front.
Sorry, and thankyou. :)

Greg

Link to comment
Share on other sites

This topic is 715 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.