Separate text from a txt file in cells of a data table


I have an accounting report, from which I have to extract the data to an excel file, the columns do not have any text delimiter since they are divided only by spaces and the number of spaces is variable, since in some cases the amount is of 3 digits but can be up to 9 digits or more. So some rows of the columns only have a space of separation while other rows of the same column have 9 spaces or 8 or 7, etc.

My question is how can I separate the data and enter it in its respective cell. I was using a substring with split to separate where there is a space, but I also have words in the row that should be in the same cell and are separated by a single space.

Does anyone have any ideas?

yourData = Regex.Replace(extractedData, "\s+", " ")

Use Regex expression to replace one or more spaces with single space and then save to excel file with a delimiter as space.

Karthik Byggari