May 12, 20223 yr 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
May 12, 20223 yr Just curious why you cannot simply import the file using Filemaker's native Import Records command/script step.
May 12, 20223 yr 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... } )
May 12, 20223 yr Author 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
Create an account or sign in to comment