csv_to_pandadf.py 524 B

1234567891011121314151617181920212223242526
  1. import pandas
  2. import csv
  3. import re
  4. #data_df = pandas.read_csv("values.csv", sep=",")
  5. #print(data_df.head(3))
  6. #data = data_df[["X1","Y1","X2","Y2"]]
  7. #print(data)
  8. text = []
  9. with open('text_merged.csv', 'r') as csvFile:
  10. reader = csv.reader(csvFile, delimiter=",")
  11. for row in reader:
  12. text.append(row[2])
  13. csvFile.close()
  14. ###extract ISOs
  15. matches = []
  16. regex = r"(ISO\s\d\d\d\d?\W?\d?\W?\d?\W?\d?)"
  17. for line in text:
  18. match = re.findall(regex, line)
  19. if match:
  20. matches.append(match)
  21. print(matches)