Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help with reading file into FORTRAN

  1. Jun 9, 2010 #1
    Hey all,

    I'm in the process of writing a Suggested Reorder Program for my father's small business..

    His current computer program exports its item data in the form of .CSV files. I'm trying to read the file into FORTRAN to manipulate. However, I run into the following problem:

    Even though the file is Comma Separated, I can't use the unformatted READ command because the file also contains the item descriptions which contain spaces... If I try to use the unformatted READ command, ever line is broken down differently after getting to the item description because it uses the spaces as breaks just like the commas..

    To further complicate things, I cant use (to my knowledge) a formatted READ command because some fields (such as the item number) are not of uniform length.. This makes it so I can't set column widths to separate the data.. It seems as though no matter if I use the formatted or unformatted READ command, some of the data ends up getting split into two columns..

    Is there any suggestions on how I could either tell the formatted READ command to separate by commas or tell the unformatted command to ignore spaces?

    Or ANY other ideas? I know my knowledge of FORTRAN command options/formatting isn't the best.. I basically know the commands and only the most common of their options/formatting.

    Heres an example of the data I need to read:

    0560380,560380,HWH DRILL SCREW 1/4*14X1-1/2,008236127317, 1, 1,N,H,2, $22.99,EA, 1, 1,099,010,00/00/00,00/00/00, $0.00, 1,560380, $20.69, $19.54, $18.39, $17.24,00003,02/13/09

    If all else fails, I guess I could read it as a single STRING and check that character by character for the appropriate number of commas for the column desired then assign them to a variable to store.. But I'd REALLY rather avoid that.
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted