| 33 | namespace { |
| 34 | |
| 35 | Status RunMain(int argc, char** argv) { |
| 36 | const char* csv_filename = "test.csv"; |
| 37 | const char* arrow_filename = "test.arrow"; |
| 38 | |
| 39 | std::cerr << "* Reading CSV file '" << csv_filename << "' into table" << std::endl; |
| 40 | ARROW_ASSIGN_OR_RAISE(auto input_file, arrow::io::ReadableFile::Open(csv_filename)); |
| 41 | ARROW_ASSIGN_OR_RAISE(auto csv_reader, arrow::csv::TableReader::Make( |
| 42 | arrow::io::default_io_context(), input_file, |
| 43 | arrow::csv::ReadOptions::Defaults(), |
| 44 | arrow::csv::ParseOptions::Defaults(), |
| 45 | arrow::csv::ConvertOptions::Defaults())); |
| 46 | ARROW_ASSIGN_OR_RAISE(auto table, csv_reader->Read()); |
| 47 | |
| 48 | std::cerr << "* Read table:" << std::endl; |
| 49 | ARROW_RETURN_NOT_OK(arrow::PrettyPrint(*table, {}, &std::cerr)); |
| 50 | |
| 51 | std::cerr << "* Writing table into Arrow IPC file '" << arrow_filename << "'" |
| 52 | << std::endl; |
| 53 | ARROW_ASSIGN_OR_RAISE(auto output_file, |
| 54 | arrow::io::FileOutputStream::Open(arrow_filename)); |
| 55 | ARROW_ASSIGN_OR_RAISE(auto batch_writer, |
| 56 | arrow::ipc::MakeFileWriter(output_file, table->schema())); |
| 57 | ARROW_RETURN_NOT_OK(batch_writer->WriteTable(*table)); |
| 58 | ARROW_RETURN_NOT_OK(batch_writer->Close()); |
| 59 | |
| 60 | #ifdef ARROW_EXAMPLE_S3_STATIC_CHECK |
| 61 | std::cerr << "* Verify S3 initializes and finalizes" << std::endl; |
| 62 | ARROW_RETURN_NOT_OK(arrow::fs::EnsureS3Initialized()); |
| 63 | ARROW_RETURN_NOT_OK(arrow::fs::EnsureS3Finalized()); |
| 64 | #endif |
| 65 | |
| 66 | return Status::OK(); |
| 67 | } |
| 68 | |
| 69 | } // namespace |
| 70 |
no test coverage detected