Fortran Help with reading file into FORTRAN

  • Thread starter DoktorD
  • Start date
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.
 

DrClaude

Mentor
6,807
2,923
I don't see a way to do this simply in Fortran. It is not the best language for processing input or string manipulation.
 

Want to reply to this thread?

"Help with reading file into FORTRAN" You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top