0

Hi,

I am pretty new to c# presently. I have a text file called tc.txt (comman separated) with the following content below:


T001,Dirks,c:\dirks\001.tif
T001,Dirks,c:\dirks\002.tif
T002,Matt,c:\matt\003.tif
T002,Matt,c:\matt\004.tif
T003,Ted,c:\Ted\005.tif
T003,Ted.c:\Ted\006.tif

When the file is read and written to another text file called output.txt (comma seperated). every line within the same folder should be written as follow;

T001,Dirks,c:\dirks\001.tif,c:\dirks\002.tif
T002,Matt,c:\matt\003.tif,c:\matt\004.tif
T003,Ted,c:\Ted\005.tif,c:\Ted\006.tif

Any help will be appreciated.

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by NET-Developer
0

This is pretty straight forward string manipulation. Read each line into a buffer then, just concatenate every two lines. chop out the parts you don't need. Every two lines could be accounted for using the mod operator.

0

It could be better to keep lines in Dictionary<string, Collection<string>), where T001, T002 etc is key, and string with filename is a part of value collection. Advantage of this way is that it is OK if source strings are mixed up (T001, T003, again T001, T002 etc), and every T... may contain any number of lines, but not only two.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.