Gokul001 Interview Questions

Continuing the discussion from Convert txt to excel?:Hi sir I want to answer the interview question but i don’t understand the question I know its about how to convert text data excel conversion but the question I don’t know where to start?
I will paste the question here please guide me.
Below are the question:
For this part of the test, you are required to convert the text file "Data\Margin Detail Report _ SD Test.txt" into a format that can be loaded into Excel. The main challenge here is that the columns are not delimited by symbols or tabs , but instead spaces. Spaces between columns are not standardized, hence Text-to-column function in Excel simply does not work. A hint would be the employment of Regex Functions in any Text Editor platform, i.e. Notepad++
For your reference, the desired output should be similar to the excel file we have attached in Data\Desired Result\Desired
Outputs_ 01.xlsx
The output of your work should be saved into Data\Outputs


Basically you can split the data from
Text into multiple lines first to seggregate each line using environment.Newline

Then loop through each line using for each activity and then inside that use a regex.Split(currentitem,"\s+").Select(function(x) Not String.IsNullOrEmpty(x)).ToArray in the array roe property of add datarow and add each row to datatable …this regex will split the data with more than one space.this will also remove any empty entries

Then you can write the data to excel

Hope this helps


Thank you so much but am junior level am applied for junior position might take sometime to understand. May i get your email please sir please

1 Like