1
votes

This is a fraction of my txt file:

Model OIII NII Ha Teff z

0 0.6838 0.0931 2.8594 42000 0

1 0.7264 0.0887 2.8602 42000 -0.05

2 0.7771 0.0828 2.8606 42000 -0.1 

3 0.9148 0.0742 2.8604 42000 -0.2

4 1.1198 0.0686 2.8586 42000 -0.3

5 0.9331 0.0835 2.8565 44000 0

6 0.9833 0.0798 2.8568 44000 -0.05

7 1.4686 0.0255 2.8469 44000 -0.1

8 1.6641 0.0241 2.8460 44000 -0.2

9 1.9533 0.0235 2.8437 44000 -0.3

I'm trying to read in the file using the following code:

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

df = pd.read_table('D:/Tareas/Malla.txt', delimiter=" ", header = 0)
#Densidad
Z = df.loc[:, 'z']
#oxígeno
O3_0 = df.loc[:4, 'OIII'] 
O3_1 = df.loc[5:9, 'OIII'] 
#Nitrógeno
N2_0 = df.loc[:4, 'NII']
N2_1 = df.loc[5:9, 'NII'] 
#Alpha
Halpha_0 = df.loc[:4, 'Ha'] 
Halpha_1 = df.loc[5:9, 'Ha'] 

#Todos
allyO = df.loc[:, 'OIII']
allxN = df.loc[:, 'NII']
allxHa = df.loc[:, 'Ha']

ex = np.log10(allxN/allxHa)
ey = np.log10(allyO)

But when I want to read it I have this error: "ParserError: Error tokenizing data. C error: Expected 6 fields in line 4, saw 7". I hink it's due to my negative values but I don't know how to fix it.

Please post a portion of the text file in the original question. I'm not downloading nor opening untrusted files from Google Drive, and you'd likely do the same if I was the asker and you were the answerer.BrokenBenchmark
@BrokenBenchmark Thanks, there it is:)Hache 99