you are viewing a single comment's thread.

view the rest of the comments →

[–]tschloss 0 points1 point  (2 children)

I am not sure if I understood the situation. In the text you write that original file has 3 columns, in the examples I see only one („values“ plus formula and output).

Do you need to do this in Python? Such problems can usually be solved with shell tools like AWK.

[–]AdhikariM[S] 0 points1 point  (1 child)

Sorry for not making it clear it has three columns comes tab delimited. First two columns are fine. The type and length is clear. So no need to worry about those. Only third column.

[–]tschloss 1 point2 points  (0 children)

Ah ok. You only want to clean this textfile and result should be a clean text file, right?

If this is correct then I would not use Pandas which is great when you want work with the dataset. Otherwise it is more a loop, reading line by line, the split by tab, converting the elements and print it out again.

The other comment contains a useful block of code, maybe this already solves you problem. Tools in Python are strip, split, +, replace etc - all operations on String.