Jump to content

Parsing csv file


Recommended Posts

  • Newbies

I am trying to import a csv file and parse it into an fmp table on fmp go 19.  The import and parsing are working well on a pc.  On my ipad, I am able to import the csv file, but the parsing is creating a blank record for every record parsed.  I suspect it is due to the effort to replace the ipad line feed character with a character return.  My code is

# Replace windows CRLF
If [ PatternCount ( Import CSV::Text ; Char ( 13 ) & Char ( 10 ) ) ]
Set Field [ Import CSV::Text; Substitute ( Import CSV::Text ; Char ( 13 ) & Char ( 10 ) ; "¶" ) ]
End If
#Replace iOS Unix (LF)
If [ PatternCount ( GetAsText ( Import CSV::Text ) ; Char ( 10 ) )]
Set Field [ Import CSV::Text; Substitute ( Import CSV::Text ; Char ( 10 ) ; "¶" ) ]
End If

Also, what is the ipad based file path format, how many slashes following file:, I have seen several different formats based on which version of FM go.

 

Thanks

 

Ron

Link to comment
Share on other sites

We don't see the actual file, and we don't see how exactly you parse it - so this is pure guesswork. I would guess that if you're getting blank records, then you have blank lines in the source. You can test for this by looking at ValueCount ( Import CSV::Text ) and PatternCount ( Import CSV::Text ; "¶¶" ).

BTW, there is no need to test for the presence of a pattern before substituting it. If the pattern doesn't occur, Substitute() will not do anything. And I would use a variable as the target instead of the original field.

Link to comment
Share on other sites

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.