I am very new to Python. I know that this has already been asked, and I apologise, but the difference in this new situation is that spaces between strings are not equal. I
You can use python pandas, I have written your data to data.csv
:
import pandas as pd
>>> df = pd.read_csv('data.csv',sep='\s+',header=None)
>>> df
0 1 2 3 4 5
0 1 C 6 0.000000 1.342650 0
1 2 C 6 0.000000 -1.342650 0
2 3 C 6 2.325539 2.685301 0
3 4 C 6 2.325539 -2.685301 0
4 5 C 6 4.651077 1.342650 0
5 6 C 6 4.651077 -1.342650 0
...
The great thing about this is to access the underlying numpy array you can use df.values
:
>>> type(df.values)
To save the data frame with comma delimiters:
>>> df.to_csv('data_out.csv',header=None)
Pandas is a great library for managing large amounts of data, as a bonus it works well with numpy. There is also a very good chance that this will be much faster then using the csv
module.