@@ -28,7 +28,7 @@ class DataReader {
2828 }
2929
3030public:
31- DataReader (long long minDate = 0 , long long maxDate = 0 , int verbosity = 0 , const std::string& format = " json " , int tailLines = 0 )
31+ DataReader (long long minDate = 0 , long long maxDate = 0 , int verbosity = 0 , const std::string& format = " auto " , int tailLines = 0 )
3232 : minDate(minDate), maxDate(maxDate), verbosity(verbosity), inputFormat(format), tailLines(tailLines) {}
3333
3434 // Internal helper to process a stream (CSV or JSON format)
@@ -88,6 +88,7 @@ class DataReader {
8888 if (verbosity >= 1 ) {
8989 std::cerr << " Reading from stdin (format: " << inputFormat << " )..." << std::endl;
9090 }
91+ // For stdin: "csv" means CSV, anything else (including "auto" and "json") means JSON
9192 processStream (std::cin, inputFormat == " csv" , callback, " stdin" );
9293 }
9394
@@ -101,8 +102,16 @@ class DataReader {
101102 }
102103 }
103104
104- // Determine format: detect from file extension (inputFormat is only for stdin)
105- bool isCSV = FileUtils::isCsvFile (filename);
105+ // Determine format: explicit "csv"/"json" overrides, "auto" detects from extension
106+ bool isCSV;
107+ if (inputFormat == " csv" ) {
108+ isCSV = true ;
109+ } else if (inputFormat == " json" ) {
110+ isCSV = false ;
111+ } else {
112+ // "auto" or any other value: detect from file extension
113+ isCSV = FileUtils::isCsvFile (filename);
114+ }
106115
107116 if (tailLines > 0 ) {
108117 // Use tail mode
0 commit comments