Actually this works nicely with filter
:
import csv
fp = open('samples.csv')
rdr = csv.DictReader(filter(lambda row: row[0]!='#', fp))
for row in rdr:
print(row)
fp.close()
More Related Contents:
- Update a CSV file?
- How do I read and write CSV files with Python?
- How to get rid of “Unnamed: 0” column in a pandas DataFrame read in from CSV file?
- Python convert csv to xlsx
- CSVWriter not saving data to file the moment I write it
- Python CSV to SQLite
- Save Dataframe to csv directly to s3 Python
- Writing to CSV with Python adds blank lines [duplicate]
- Panda’s Write CSV – Append vs. Write
- Python DictWriter writing UTF-8 encoded CSV files
- Numpy loading csv TOO slow compared to Matlab
- Error “(unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape” [duplicate]
- How to read one single line of csv data in Python?
- Pandas dataframe read_csv on bad data
- Speeding (Bulk) Insert into MySQL with Python
- Proper way to reset csv.reader for multiple iterations?
- Do comments slow down an interpreted language?
- AttributeError: ‘module’ object has no attribute ‘reader’ [duplicate]
- Find all CSV files in a directory using Python
- Calculate summary statistics of columns in dataframe
- Extract csv file specific columns to list in Python
- double quoted elements in csv cant read with pandas
- Python – re-ordering columns in a csv
- ValueError: not enough values to unpack (expected 11, got 1)
- how to specify the datetime format in read_csv
- UnicodeDecodeError when reading CSV file in Pandas
- How to upload a CSV file in FastAPI and convert it into JSON?
- How to return a csv file/Pandas DataFrame in JSON format using FastAPI?
- ValueError: x and y must be the same size
- Python: Writing Nested Dictionary to CSV