Jump to content

Parsing csv file


moleanardo
 Share

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

Recommended Posts

  • Newbies

Hi,

I have a .csv file (comma seperated file) that I need to import into filemaker and am having trouble doing it. The file looks like this:

Field1 name, field value1

Field2 name, field value2

Field2 name, field value3

If I import the file, FM wants to make each line a new record. I would like it to search for the field name in the .CSV then pull the value (after the comma) and then populate that field with the value. When all done, I should have one new record for the entire imported .csv file. I also can not assume that each .csv file will have the same fields on the same lines each time I import a new file. I tried looking for a parser plug in with no luck. I tried writing a script and am having trouble. Does anyone know of a plug in that can handle this or a script example of how to accomplish this?

My current script was able to import the file into a temporary database file that imports each line into a new record and the two sections (before and after the comma) into two fields. Then I relate that file to my master database and view each record in the related file and perform a loop script for each record. The problem is that the script is getting pretty complicated (I can't figure it out) and I would rather buy a plug-in or simplify the script in some way.

Thanks in advance,

John Molinari

Santa Rosa, CA

Link to comment
Share on other sites

With comma (and tab) delimited files, the FIELDS are delimited by commas (or tabs) while the records are delimited by paragraph marks.

I just did a test, and my csv file looked like this:

"field1", "field2". "field3", "field4"

"field1", "field2". "field3", "field4"

"field1", "field2". "field3", "field4"

"field1", "field2". "field3", "field4"

"field1", "field2". "field3", "field4"

There were no field names at the start, the field data was surrounded by double-quotes and each record was on a new line. Are you sure you are working with a CSV file?

Link to comment
Share on other sites

quote:

Originally posted by moleanardo:

Field1 name, field value1

Field2 name, field value2

Field2 name, field value3


The biggest problem you will have is that this is NOT a comma-seperated file (i.e. *.CSV). This is a special kind of delimited file. You will most likely need to run this through something else (like Excel or Word) first, then structure the data into a true database format before importing into Filemaker.

Databases are typically structured to delimit each field by some value (Tab, Comma, etc) and delimit each record by a paragraph return. Depening upon the specific format they may or may not encapsulate the field values in quotes and may or may not include the field names as the first record.

Link to comment
Share on other sites

  • Newbies

You are both correct, this is a special kind of csv. It is generated from a measurement instrument that allows me to view the values that was read by the instrument. In order to determine what value is associated with which description, it lays it out by showing the label followed by the value.

For example:

Measurement 1, result

Measurement 2, result

My problem is that I want to automate this process in an application. This way a user can choose a button (script in FM) and import this special csv and format it automatically. Ideally, a script would do this, even though a plug-in would be easier to implement. I could always write a Visual Basic application to search for each known label (field name) and value and then output a proper .csv that is only values put in the order which the FM import expect. This way when I import it into FM, the fields are the only thing in the imported csv file. I just wanted to avoid the interim process and import it directly into FM.

-John Molinari

Link to comment
Share on other sites

This topic is 7247 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
 Share

×
×
  • Create New...

Important Information

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