Looping through lines in a .csv file?

thomastthomast Member Posts: 102
Hi Guys,

Does any of you know how I loop through a number of lines when importing a csv file? I'm using the file-variable for the import.

I need to csv file contains sales lines from another system which needs to go into a sales journal.

Thanks, Thomas

Comments

  • vaprogvaprog Member Posts: 1,141
    Use File.POS at the beginning of the loop and File.SEEK to get back to that point.

    Why would you need such a thing? If you cannot process the lines in the order they appear in the csv I recommend to use a buffer table and a regular dataport to populate it.

    I case you just wanted to know how to process a csv file without using a dataport, please use the Search the forum feature.
  • thomastthomast Member Posts: 102
    Hi Vaprog,

    Thanks for your reply!

    Yes, I just need to know how to import a .csv file without using a dataport/xmlport. I searched the forums but were not able to find a thread. Can you (or anyone else) refer me to a good thread on this task?

    Thanks, Thomas
  • vaprogvaprog Member Posts: 1,141
    Well, you have to write a parser for it. It's not difficult but work.

    Here's some code someone posted. I did not use it. Don't know how well it works for which scenario. It might give you a start.

    Here's some info for when your lines might be too long or your fields might contain quoted record separators (CR LF, usually).

    And here are some general remarks concerning the .csv format.
  • thomastthomast Member Posts: 102
    Thank you vaprog!!!
Sign In or Register to comment.