Fortran Help with reading file into FORTRAN

AI Thread Summary
The discussion revolves around challenges faced while attempting to read and manipulate .CSV files in FORTRAN for a Suggested Reorder Program. The primary issue arises from the presence of spaces within item descriptions, which disrupts the use of the unformatted READ command, as it treats spaces as delimiters. The formatted READ command is also problematic due to non-uniform field lengths, making it difficult to set fixed column widths for data separation. Suggestions sought include methods to either configure the formatted READ command to recognize commas as separators or to modify the unformatted command to ignore spaces. An alternative approach considered is reading the entire line as a single string and parsing it character by character, although this is seen as a less desirable solution due to the complexity of string manipulation in FORTRAN.
DoktorD
Messages
6
Reaction score
0
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 can't 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.
 
Technology news on Phys.org
I don't see a way to do this simply in Fortran. It is not the best language for processing input or string manipulation.
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Replies
8
Views
1K
Replies
12
Views
3K
Replies
5
Views
5K
Replies
2
Views
3K
Replies
16
Views
3K
Replies
5
Views
2K
Replies
2
Views
2K
Replies
1
Views
3K
Back
Top