I'm still new to Pandas. Is it possible to initiate and append to a Pandas dataframe while looping over lines? My attempt is below, but it creates a dataframe with 1 column instead of 6 columns. Would it be easier to just save the modified input to a csv file and then read that csv file with Pandas? I'm probably going to do that now. Thanks!
import requests
import pandas as pd
url = 'https://raw.githubusercontent.com/23andMe/yhaplo/master/input/isogg.2016.01.04.txt'
r = requests.get(url)
for i, line in enumerate(r.text.splitlines()):
l = line.strip().split('\t')
## The header is on the first line.
if i == 0:
df = pd.DataFrame([s.strip() for s in l])
## Lines with 6 columns.
elif len(l) == 6:
df = df.append(pd.DataFrame([s.strip() for s in l]))
## Lines with 7 columns.
elif len(l) == 7:
df = df.append(pd.DataFrame([l[i].strip() for i in (0, 2, 3, 4, 5, 6)]))