Jul-22-2018, 11:30 AM
I have a functioning code to skip the meta data in a .csv file using Python. However, I cannot understand what this part of the code is doing:
https://i.stack.imgur.com/uS4zJ.jpg
else:
if not col:
continue #No columns found yet
else:
i+=1 #Last column found
break The whole code is as follows:def readPandoraCSV(file):
with open(file) as f:
lines=f.readlines()
col=0
for i in range(len(lines)):
line=lines[i]
if line[0:6]=='Column':
col+=1
else:
if not col:
continue #No columns found yet
else:
i+=1 #Last column found
break
df=read_csv(file,skiprows=range(i),header=None)
try:
df['JDate']=df[df.columns[0]].apply(getJD)
df=df.drop(df.columns[0],1)
except:
df['JDate']=df[df.columns[1]].apply(getJD)
df=df.drop(df.columns[1],1)
return dfThe meta data in the .csv file looks as follows:https://i.stack.imgur.com/uS4zJ.jpg
