![]() |
|
#1
|
|||
|
|||
Using fopen on multiple filesI have about 100 csv files that I want to open. Each csv file containts similar data, and I need to analyse the first line of each csv file. The problem is how do I loop around fopen. Each csv file has incrememnting file numbers, so file1, file2, file3 ... The obvious solution is call fopen 100 separate times, but that is just being stupid.
|
|
#2
|
|||
|
|||
|
I am assuming you want to know how to set up the file name for the files....
If that is the case, and the files are as you suggest... CPP / C++ / C Code:
Just replace file_pat to fit your actual pattern (or use your pattern directly in the snprintf statement) If you are talking about files that may or may not be in order (some numbers may be missing) and/or the number of files isnt know, you can use opendir and sscanf. If that is what you want post back and I'll give an example... |
|
#3
|
|||
|
|||
|
I think the best way to explain what I have done is by showing you:
This is what I have so far, and seems to work fine CPP / C++ / C Code:
As you can see the problem is having 100 arguments on the command line. Last edited by LuciWiz : 28-Jul-2005 at 02:22.
Reason: Please insert your C code between [c] & [/c] tags
|
|
#4
|
|||
|
|||
|
So have the program take a format string as the argument.
for instance: ./program file_name_%03d.csv Or some such that will match the pattern of your file. |
|
#5
|
|||
|
|||
|
Quote:
Have tried what you mentioned, but cannot seem to get it in the correct format The file names are form1.cvs, form2.cvs ... |
|
#6
|
|||
|
|||
|
Quote:
|
Recent GIDBlog
Developing GUIs with wxPython (Part 3) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| multiple file creation with fopen? | robin | C Programming Language | 6 | 16-Aug-2006 23:38 |
| Linker errors with multiple file progam | nkhambal | C Programming Language | 2 | 24-Apr-2005 02:37 |
| controling dialog objects & multiple source files | omills | MS Visual C++ / MFC Forum | 0 | 14-Jul-2004 23:30 |
| Apache2 config issues | monev | Apache Web Server Forum | 2 | 28-Jun-2004 06:19 |
| Can't view pages from another machine on the Intranet | aevans | Apache Web Server Forum | 9 | 14-May-2004 02:26 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The