Difference between revisions of "Pandas parsing delimited file"
Jump to navigation
Jump to search
(Created page with " # No header space delimited ``` import pandas as pd df = pd.read_csv('virtualsevers.out', header=None, sep='\s+') df[0][0] for index, row in df.iterrows(): if row[3] != '0...") |
|||
Line 3: | Line 3: | ||
``` | ``` | ||
import pandas as pd | import pandas as pd | ||
+ | from tabulate import tabulate | ||
df = pd.read_csv('virtualsevers.out', header=None, sep='\s+') | df = pd.read_csv('virtualsevers.out', header=None, sep='\s+') | ||
df[0][0] | df[0][0] | ||
+ | print(tabulate(df, showindex=False, headers=df.columns)) | ||
for index, row in df.iterrows(): | for index, row in df.iterrows(): | ||
− | if row[3] != '0': | + | if row[3] != '0' or row[4] != '0' or row[9] != '0': |
print(row[0]) | print(row[0]) | ||
+ | print(tabulate([row])) | ||
+ | # pp.pprint(row.to_frame().T) | ||
``` | ``` |
Latest revision as of 18:04, 6 August 2023
No header space delimited
import pandas as pd from tabulate import tabulate df = pd.read_csv('virtualsevers.out', header=None, sep='\s+') df[0][0] print(tabulate(df, showindex=False, headers=df.columns)) for index, row in df.iterrows(): if row[3] != '0' or row[4] != '0' or row[9] != '0': print(row[0]) print(tabulate([row])) # pp.pprint(row.to_frame().T)