csv_to_text.py 608 B

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