Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    173

    Need to parse data from CSV Files

    Hi

    I need to be able to parse some specific data from CSV Files so i can use that data into my AMS4 project? I searched the internet for a DLL that would do that and that i could use in my project but didnt find one! Anyone can help me with that?

    I am sure there is someone here that could help me with that!

    thanks in advance

    Martin

  2. #2
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Do you have a sample of the data from a csv file you want to parse. If it is always in the same order, you could use the String.GetDelimited function and use the "," as a delimiter.

  3. #3
    Join Date
    May 2003
    Location
    Pendleton, Oregon
    Posts
    1,038
    AMS has that ability built in. In the available actions list in the String Actions, use Get Delimited String. Use a comma for the delimiter.

  4. #4
    Join Date
    May 2003
    Location
    Pendleton, Oregon
    Posts
    1,038
    Hey Tigg, it looks like you are a faster typer than I am, so yea, I second what you said.

  5. #5
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    173
    Thanks guys for repying! Here is a sample of the file:

    "AHA05","","AHA05","","Analog"
    ""
    "AHA12","","AHA12","","Analog"
    ""
    "AHP05","","AHP05","","Analog"
    ""
    "AHP12","","AHP12","","Analog"
    ""
    "AKP12","","AKP12","","Analog"
    ""
    "ALMCOA","","ALMCOA","","Digital"
    ""
    "ALMCOB","","ALMCOB","","Digital"
    ""
    "APA05","","APA05","","Analog"
    ""
    "APP12","","APP12","","Analog"
    ""
    "APP25A","","APP25A","","Analog"
    ""
    I will try to use the get delimited string action as you suggested!

    Thanks again!

    Martin

  6. #6
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Martin, don't forget the quotation marks will be part of each item if you use a comma as the deilmiter. If you don't want that to be the case simply add a STRING > REPLACE action to strip the quotations marks afer you get the item data...

    Corey Milner
    Creative Director, Indigo Rose Software

  7. #7
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    173

    other problem

    Guys,

    The string delimited action works fine, but a problem came up and i cant pinpoint what is causing it. Once i retrieved all the needed objects from the csv file, i then send the list of items to a listbox object, and for some reason, there are 2 squares that appears in front of each point names!! I attached a screenshot for you to look at. If anybody can explain to me how to get rid of that. that would be greatly appreciated.

    Thanks

    Martin
    Attached Images

  8. #8
    Join Date
    May 2003
    Location
    Pendleton, Oregon
    Posts
    1,038
    I’ve seen this sort of thing happen when a text file gets downloaded in binary format instead of ASCII format. It has to do with the different ways that UNIX and Windows format line breaks and carriage returns. Try opening the CVS file in Notepad, do you see the same thing? You may have to massage your CVS file a bit. You might want to search the forum for #ASC_LF# to get more info.

    Worm helped me out when I was having some similar problems, and he sent me some instructions. I’ll try to reword them a bit here to make them more appropriate for your situation.

    First you need to define a couple of constants.

    Intructions to define a constant for Carriage Return and Line Feed.
    1. Click on Project
    2. Choose Settings
    3. Click on the Configurations TAB
    4. Click on Default Build (in the left pane)
    5. Click on the Note Icon with the Red Arrow under the Constants Box
    6. Define the constant like this

    Name: #ASC_CR#
    Value: 13
    Comment: Carriage Return

    The click on OK.

    7. Click on the Note Icon with the Red Arrow under the Constants Box (again)
    6. Define the constant like this

    Name: #ASC_LF#
    Value: 10
    Comment: Line Feed

    The click on OK.

    8. Close out the Project Settings Box.

    How to use them

    1. Use AMS's actions to do replace all instances of a Carriage Return/Line Feed with only a Line Feed

    %OrigionalCVSTextFile% =TextFile.Read ("%SrcDir% \cvs.txt")
    %NewCVSFile% = String.Replace ("%OrigionalCVSTextFile% ", "#ASC_CR##ASC_LF#", "#ASC_LF#")

    2. Now replace all instances of a Line Feed, with a Carriage Return/Line Feed
    %NewCVSFile% = String.Replace ("%OrigionalCVSTextFile% ", "#ASC_LF#", "#ASC_CR##ASC_LF#")

    3. The variable %NewCVSFile% will hold the corrected version of the CVS file.

    I hope this works for you. Let me know if you need more help.
    If it does work, and I’m pretty sure it will, remember all credit goes to Worm. I’m just the messenger.

  9. #9
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    As you guys have probably heard new version of AMS 5.0 is out this week. It has provision for the UNIX format snafu.

    Corey Milner
    Creative Director, Indigo Rose Software

  10. #10
    Join Date
    May 2003
    Location
    Pendleton, Oregon
    Posts
    1,038
    Does that mean that download web file will let us choose between binary and ASCII formats? What else can we look forward to? I knew it was coming someday but I can’t find anything about it on your site. Hats off to Lorne and the rest, for coming up with features that Worm hasn’t already created a DLL for. I can’t wait to see what’s in store. Now that you let the cat out of the bag on the time table, I’ll find it as hard to go to sleep as a 6 year old on Xmas eve. Any chance we can get a sneak peek at the feature set? I guess I better start saving my pennies for the upgrade.

  11. #11
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    I can't say anything more for now. But it'll all be on the site this week so you won't have to wait very long... But as to your first question, yes it will allow you to do that.

    Corey Milner
    Creative Director, Indigo Rose Software

Similar Threads

  1. rename multiple files
    By jenny62 in forum Setup Factory 6.0
    Replies: 1
    Last Post: 04-13-2004, 01:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts