Changeset 7109
- Timestamp:
- May 28, 2009, 9:24:00 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/numpy/anuga/utilities/csv_tools.py
r7101 r7109 13 13 '''Select key and value columns from 'N' CSV files, write one CSV file. 14 14 15 file_title_list: a list of (filename, new_ value_column_title) values, one16 for each file15 file_title_list: a list of (filename, new_data_column_title) values, one 16 for each input file 17 17 output_file: the output CSV file path 18 18 key_col: column header string of key column 19 data_col: column header string of valuecolumn19 data_col: column header string of data column 20 20 21 21 The output file will look like: 22 <key_col>, <new_ value_column_title1>, <new_value_column_title2>, ...23 <key_value>, <data1>, <data2>,...24 <key_value>, <data1>, <data2>,...25 <key_value>, <data1>, <data2>,...26 <key_value>, <data1>, <data2>,...22 <key_col>, <new_data_column_title1>, <new_data_column_title2>, ... 23 <key_value>, <data1>, <data2>, ... 24 <key_value>, <data1>, <data2>, ... 25 <key_value>, <data1>, <data2>, ... 26 <key_value>, <data1>, <data2>, ... 27 27 28 28 There is an assumption that the <key_value> values are the same across … … 76 76 file_data.append((filename, title, data)) 77 77 78 # now, file_data -> [(filename, title, [(k,v), (k,v), ...] ]78 # now, file_data -> [(filename, title, [(k,v), (k,v), ...], ...] 79 79 # sanity check, check num rows same in all files 80 80 num_rows = None … … 103 103 104 104 # write column rows to output file 105 # at this point, file_data=[(<filename>, <col_title>, [(k,v), ...]), ...]106 105 header = [key_col] 107 106 for (fn, col, d) in file_data:
Note: See TracChangeset
for help on using the changeset viewer.