I've been out of the coding game for a few years now so I'm pretty rusty - feels like I'm starting from scratch so I apologize if this a rookie question.
I have a text file with line items:
> 076-5000-3ABBOTT 1998010700019900119971205000
048-0002-8ABINGDON 1998010700019900119971205000
100-5000-3ABSHER 1998010700019900119971205000
I also have a layout key:
Blockquote
- Location-Code-Id PIC X(10) Value "xxx-xxxx-x"
- Location-Name PIC X(25)
- Current-Rate-Effective-Date PIC X(6) Value "CCYYMM"
- Total-Current-Telecom-Rate PIC 9(5) A 7.00% rate would be 07000
- Previous-Rate-Effective-Date PIC X(6) Value "CCYYMM"
- Previous-Rate-Ending-Date PIC X(6) Value "CCYYMM"
- Total-Previous-Telecom-Rate PIC 9(5) A 7.00% rate would be 07000
The total length of each string is 63. I basically need to split the string up by the PIC X lengths and then convert them to the titles ie. "Location-code-Id," which will ultimately be a column header.
This is what I currently have:
class ReadFromFile
{
static void Main()
{
string[] lines = System.IO.File.ReadAllLines(@"C:\Files\test.txt");
// Display the file contents by using a foreach loop.
System.Console.WriteLine("Contents of test.txt = ");
foreach (string s in lines)
{
string s = s;
foreach (char c in s)
{
if (s.Length = 10)
{
Console.WriteLine(s.Length);
}
else if (s.Length = 35)
{
Console.WriteLine(s.Length);
}
else
{
Console.WriteLine(s);
}
}
}
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
System.Console.ReadKey();
}
}
This code doesn't work obviously, and I didn't write it to print out text yet, I just wanted to print out the current length position so that I could go from there. Pretty lost at the moment. I ultimately want to convert this to JSON or CSV. Any help would be appreciated, thanks a ton.