import csv from StringIO import StringIO def parse_to_get_record( csv_content ): """ According to csv to parse result. """ csv_lines = csv_content.splitlines() # 還可以濾掉某些不要的行 csv_reader = csv.reader( StringIO( '\n'.join(csv_lines[2:-2]) ) ) result = [] for row in csv_reader: print( row ) result.append( row ) return result f = open('d:\\tmp\\aaa.csv', 'r') s = f.read() print( parse_to_get_record(s) )
沒有留言:
張貼留言