I need to combine several TXT files, the number of files may vary, and the data contents of the files will need to be in specific places in the combined file. Some of the data files will be similar as will contain values at different time steps. Each of the files will contain their own variables, but the combined file needs all the variables, and the data for those variables in their own columns. One of my problems is that some files that contain data for different timesteps does not contain all the same columns, but one column that is shared. More specifically, some files contain xy coordinates along with a node number for those coordinates, while other files only have the node numbers. These are just straight text data files... no database or XML is used. If anyone has had a similar situation or has an idea of how I can do this, I'd appreciate the help. Here's a simplified example of what I'm trying to do:

File 1:

TITLE = "Title"
VARIABLES = "X" "Y" "node" "A" "B" "C"
ZONE T ="T1", N =  5, E =  3
   0.000   0.000   00001   0.0000   0.0000   0.0000
  10.000   0.000   00002   0.0000   0.0000   0.0000
  20.000   0.000   00003   0.0000   0.0000   0.0000
  15.000   5.000   00004   0.0000   0.0000   0.0000
   5.000   5.000   00005   0.0000   0.0000   0.0000
      1     2     5
      2     3     4
      4     5     2


File 2:

ZONE T ="T2", N =  5, E =  3
   00001   0.2200   0.2200   0.0000
   00002   0.4400   0.4400   0.0000
   00003   0.6600   0.6600   0.0000
   00004   0.8800   0.8800   0.0000
   00005   1.0100   1.0100   0.0000


File 3:

TITLE = "Title"
VARIABLES = "X" "Y" "node" "D" "E"
ZONE T ="T1", N =  5, E =  3
   0.000   0.000   00001   0.0000   0.0000
  10.000   0.000   00002   0.0000   0.0000
  20.000   0.000   00003   0.0000   0.0000
  15.000   5.000   00004   0.0000   0.0000
   5.000   5.000   00005   0.0000   0.0000
      1     2     5
      2     3     4
      4     5     2


File 4:

ZONE T ="T2", N =  5, E =  3
   00001   0.0330   0.0808
   00002   0.0550   0.0707
   00003   0.0770   0.0606
   00004   0.0990   0.0505
   00005   0.2020   0.0101


File 5:

VARIABLES = "X" "Y" "node" "F" "G" "H"
ZONE T = "R", N =  5, E =  3
   0.000   0.000   00001   0.0000   0.0500   0.0010
  10.000   0.000   00002   1.0000   0.0600   0.0030
  20.000   0.000   00003   2.0000   0.0700   0.0050
  15.000   5.000   00004   3.0000   0.0800   0.0070
   5.000   5.000   00005   4.0000   0.0900   0.0090
      1     2     5
      2     3     4
      4     5     2



Combined File:

TITLE = "Title"
VARIABLES = "X" "Y" "node" "A" "B" "C" "D" "E" "F" "G" "H"
ZONE T ="T1", N =  5, E =  3
   0.000   0.000   00001   0.0000   0.0000   0.0000   0.0000   0.0000   0.0000   0.0500   0.0010
  10.000   0.000   00002   0.0000   0.0000   0.0000   0.0000   0.0000   1.0000   0.0600   0.0030
  20.000   0.000   00003   0.0000   0.0000   0.0000   0.0000   0.0000   2.0000   0.0700   0.0050
  15.000   5.000   00004   0.0000   0.0000   0.0000   0.0000   0.0000   3.0000   0.0800   0.0070
   5.000   5.000   00005   0.0000   0.0000   0.0000   0.0000   0.0000   4.0000   0.0900   0.0090
      1     2     5
      2     3     4
      4     5     2
ZONE T ="T2", N =  5, E =  3
   0.000   0.000   00001   0.2200   0.2200   0.0000   0.0330   0.0808   0.0000   0.0500   0.0010
  10.000   0.000   00002   0.4400   0.4400   0.0000   0.0550   0.0707   1.0000   0.0600   0.0030
  20.000   0.000   00003   0.6600   0.6600   0.0000   0.0770   0.0606   2.0000   0.0700   0.0050
  15.000   5.000   00004   0.8800   0.8800   0.0000   0.0990   0.0505   3.0000   0.0800   0.0070
   5.000   5.000   00005   1.0100   1.0100   0.0000   0.2020   0.0101   4.0000   0.0900   0.0090
      1     2     5
      2     3     4
      4     5     2

Good luck....

From what your saying you can get any number of files containing an unspecified amount data in any order in any format and somehow you need to break the data down and match it up to produce a single file with all the data.

If I were you, I'd see if I could get my data files in set formats first. Then you could open each file, check which format it is in (by file name, or parsing the first couple of rows of data to see what is in each column then matching this to a format or any other way you have) and have a routine for processing each different format of file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.