4 Replies Latest reply on Jan 11, 2010 9:44 AM by philmodjunk

    Skipping lines on CSV import



      Skipping lines on CSV import


      Is there a way to skip say the first 5 lines of a file when importing?

      (and filed names start on line 6) 

        • 1. Re: Skipping lines on CSV import

          It seems the only way to truly "skip" the lines would be to remove them from the source. That is likely not too hard to do. But, short of using a plug-in, methods would be slightly different for Mac or Windows. I'm mostly on a Mac. 


          Using the following AppleScript, via the FileMaker Perform AppleScript step (and changing file paths to match yours), this will read lines 6 to end of a text file, and write that to a 2nd file.


          do shell script "awk 'NR>5' ~/Desktop/test.txt > ~/Desktop/test2.txt"

          -- read lines 6 to end 


          The result will be UTF-8. If you need UTF-16, for special characters, it's a bit more involved (at least for me, as I don't know how force a " > " redirect to write UTF-16 encoding; I resort to vanilla AppleScript for that). Let me know if that is required. 

          • 2. Re: Skipping lines on CSV import
               Your other option is to simply import the lines you wanted to skip and then delete them after import.
            • 3. Re: Skipping lines on CSV import

              Thanks guys.  I wanted to avoid AS (not affraid of it, but complicates things if I want to do a distro)


              Phil, can that be done when the field names are on say line 6?  (What I'm trying to do is import a CSV from my bank, first couple lines are monthly totals of withdraws and deposits, so ony a couple of 'fields'.  Will FM work ok with not filling all fields?  ) 

              • 4. Re: Skipping lines on CSV import
                   You should be able to. When the import mapping dialog pops up, you can click through the lines of text in your source file to the first true line of text and use that line to specify your field mapping. (Use the >> button.) Then you can import and simply delete the first few records of your imported data.