Hi please help, I’m trying to convert this text file to an Excel file and I need the accounting period and RI extraxt to show up. The solution i used is writing the headers in the first column (Startdate, etc.).
Excel file
Hi please help, I’m trying to convert this text file to an Excel file and I need the accounting period and RI extraxt to show up. The solution i used is writing the headers in the first column (Startdate, etc.).
Check this post if it helps.
how about creating another datatable which only keeps first 2 rows.
then while writing to excel, first you write this datatable with only 2 rows.
then you write datatable with rest of the table into excel. you may need to specify the range to start from A3 instead in this case.
Follow the below step:
1.Read the Text File.
2.filteredText = String.Join(Environment.NewLine, fileContent.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).SkipWhile(Function(line) Not line.ToLower().Contains(“startdate”)))
3.Use Generate DataTable Activity.
4.Input: filteredText,Output: myDataTable
Settings:Column Separator: ;
Mark solution if its help ![]()
Happy Automation
Hi @Pabaleloh, here are some options you can try. Let me know if any of this helps:
Option 1: Aleem’s Method (Best one)
Use Read Text File activity to read your file, then Generate DataTable with semicolon separator. For filtering the lines, use Assign activity with and handle it with an expression. Something like this:
filteredLines.SkipWhile(Function(x) Not x.Contains(“startdate”))
Then use Write Range for your RI Extract info first, then Append Range for data from A3 onwards.
Option 2: Text to Columns Method
Use a Read Text File to put everything in Excel as it is, then use Text to Columns activity to split the semicolon data. Your metadata will stay on top.
Option 3: Build Step by Step
Use Build Data Table activity to make your structure, then Add Data Row for RI Extract and Accounting Period rows, then For Each loop for your actual data.
I would suggest trying Option 1 first - Aleem’s method is good and the Generate DataTable activity will handle most of the work for you.
Try it out and tell me how it goes! ![]()
Hey @pabaleloh,try the bellow steps
Read Text File activity.Split(text, Environment.NewLine) to access specific lines.A1 → "RI Extract Summary All RI's (Revised 9 Aug)"A2 → "Accounting Period=349"Write Range and set StartingCell to “A4”This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.