NeoAgi / NeoAgi.Tools.FlatFileQuery

Other
0 stars 0 forks source link

Implement Pipe Data Input #7

Open Habikki opened 2 years ago

Habikki commented 2 years ago

The current API requires the use of a file to be included in the Query (e.g. SELECT * FROM /path/to/file.csv AS table1) which functions well in an interactive context. Automation may benefit from supplying the data in an input pipe (e.g. cat /path/to/some_*.csv | NeoAgi.Tools.FlatFileQuery --query "SELECT * FROM table1").

Habikki commented 2 years ago

This may not be as difficult as originally thought, the following quick mockup captures input if added to https://github.com/NeoAgi/NeoAgi.Tools.FlatFileQuery/blob/main/src/Worker.cs#L37:

            /* Begin Service/Worker Logic */

            // See if we can read input Pipe Data
            Stream stdin = Console.OpenStandardInput();
            byte[] buffer = new byte[8];
            int bytesRead = await stdin.ReadAsync(buffer, 0, 8);

            Logger.LogError("Read: " + System.Text.Encoding.Default.GetString(buffer));

            // We have a raw query, extract out the path of the data file