95 if (headerDone) { |
95 if (headerDone) { |
96 writer->writeAttribute(convertor.from_bytes(currentValue.str())); |
96 writer->writeAttribute(convertor.from_bytes(currentValue.str())); |
97 } else { |
97 } else { |
98 AttributeMetadata am; |
98 AttributeMetadata am; |
99 am.attributeName = convertor.from_bytes(currentValue.str()); |
99 am.attributeName = convertor.from_bytes(currentValue.str()); |
100 am.typeId = TypeId::STRING; // TODO: support also other types passed as CLI parameters |
100 am.typeId = TypeId::STRING; |
101 metadata.push_back(am); |
101 metadata.push_back(am); |
102 if (lastInRecord) { |
102 if (lastInRecord) { |
|
103 |
|
104 /* |
|
105 * Usage (simple syntax): |
|
106 * relpipe-in-csv → default relation name, attribute names on the first line, all types are string |
|
107 * relpipe-in-csv my_relation → custom relation name |
|
108 * relpipe-in-csv my_relation a b c → custom relation name, custom attribute names (a,b,c), first line contains data |
|
109 * relpipe-in-csv my_relation a integer b string c boolean → custom relation name, custom attribute names (a,b,c), custom types (integer,string,boolean), first line contains data |
|
110 */ |
|
111 |
|
112 vector<string_t> firstLine; |
|
113 if (args.size() == (1 + metadata.size())) { |
|
114 for (int i = 0; i < metadata.size(); i++) { |
|
115 firstLine.push_back(metadata[i].attributeName); |
|
116 metadata[i].attributeName = args[1 + i]; |
|
117 } |
|
118 } else if (args.size() == (1 + 2 * metadata.size())) { |
|
119 for (int i = 0; i < metadata.size(); i++) { |
|
120 firstLine.push_back(metadata[i].attributeName); |
|
121 metadata[i].attributeName = args[1 + i * 2]; |
|
122 metadata[i].typeId = writer->toTypeId(args[1 + i * 2 + 1]); |
|
123 } |
|
124 } |
|
125 |
103 headerDone = true; |
126 headerDone = true; |
104 writer->startRelation(args.size() > 0 ? args[0] : L"csv", metadata, true); |
127 writer->startRelation(args.size() > 0 ? args[0] : L"csv", metadata, true); |
|
128 if (firstLine.size()) { |
|
129 for (string_t value : firstLine) writer->writeAttribute(value); |
|
130 } |
105 } |
131 } |
106 } |
132 } |
107 |
133 |
108 currentValue.str(""); |
134 currentValue.str(""); |
109 currentValue.clear(); |
135 currentValue.clear(); |