MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / last_two_columns_repeat

Function last_two_columns_repeat

examples/src/csv_examples.cpp:333–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

331}
332
333void last_two_columns_repeat()
334{
335 const std::string holidays = R"(1,CAD,2,UK,3,EUR,4,US
33638719,2-Jan-2006,40179,1-Jan-2010,38719,2-Jan-2006,39448,1-Jan-2008
33738733,16-Jan-2006,40270,2-Apr-2010,38733,16-Jan-2006,39468,21-Jan-2008
338)";
339
340 // array of arrays
341 jsoncons::json_decoder<jsoncons::ojson> decoder1;
342 auto options1 = csv::csv_options{}
343 .column_types("[integer,string]*");
344 std::istringstream is1(holidays);
345 csv::csv_stream_reader reader1(is1, decoder1, options1);
346 reader1.read();
347 auto val1 = decoder1.get_result();
348 std::cout << "(1)\n" << pretty_print(val1) << "\n";
349
350 // array of objects
351 jsoncons::json_decoder<jsoncons::ojson> decoder2;
352 auto options2 = csv::csv_options{}
353 .header_lines(1)
354 .column_names("CAD,UK,EUR,US")
355 .column_types("[integer,string]*");
356 std::istringstream is2(holidays);
357 csv::csv_stream_reader reader2(is2, decoder2, options2);
358 reader2.read();
359 auto val2 = decoder2.get_result();
360 std::cout << "(2)\n" << pretty_print(val2) << "\n";
361}
362
363void decode_csv_string()
364{

Callers 1

mainFunction · 0.85

Calls 5

pretty_printFunction · 0.85
column_typesMethod · 0.80
get_resultMethod · 0.80
header_linesMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected