Giter Site home page Giter Site logo

Add custom column in output about usql HOT 2 CLOSED

azure avatar azure commented on May 29, 2024
Add custom column in output

from usql.

Comments (2)

lokesh-zende avatar lokesh-zende commented on May 29, 2024

I did something like this.
Declare a variable and assign datetime value in desired format to that variable.
Then use that variable with the result received by extracting a .tsv.

DECLARE @Date = DateTime.Now.ToString("yyyyMMddHHmm");

@Result = 
    EXTRACT 
            User_ID int,
            First_Name string,
            Middle_Name string,
            Last_Name string,
            Age int,
            Gender string,
            Team string
        FROM "/Users.tsv"
        USING Extractors.Tsv();

@Final = SELECT *, @Date AS Date FROM @Result;

OUTPUT @Final
TO "/UsersConverted.csv"
USING Outputters.Csv();

Though it works, I would like to know if there are any other ways to achieve this.

from usql.

MikeRys avatar MikeRys commented on May 29, 2024

If you want to add a single value to all the rows, your approach is probably the best one. You could write a custom extractor but that is too much overhead. If you have more values that you want to add depending on a value in the file, create a constant table (with SELECT FROM VALUES) and join it with the result of the extraction.

If this answers your question, please close this issue.

from usql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.