Using "Calculate Age" recipe with qsv

Created by datHere Support, Modified on Thu, 2 May at 7:53 AM by datHere Support

Usage:

  1. Before running the recipe, make sure to enter the column index which contains the birthdate in the code
  2. Use the following qsv command to calculate the age and add it as a new column named 'Age' in the CSV:
        qsv luau map 'Age' age.luau filename.csv -o newfile.csv

        

    • Replace 'age.luau' with the filename of this Lua script.
    • Replace 'filename.csv' with the name of your input CSV file.
    • The '-o' option is used to specify the output filename ('newfile.csv' in this example).

  3. Let's say you have the file and the recipe is in different location
        qsv luau map 'Age' file:<Path of the recipe> filename.csv -o newfile.csv

    When you need real-time preview of the csv file

        qsv luau map 'Age' age.luau filename.csv | qsv table

Example:

Suppose the input CSV file 'people.csv' contains a column 'Birthdate' which contains birthdates in the format 'dd-mm-yyyy'. 
To calculate the age based on these birthdates and add it as a new column named 'Age' in the CSV, use the following command:

    qsv luau map 'Age' age.luau people.csv -o people_with_age.csv

Additional Links:

Learn more about Lua command here

More Articles on qsv Recipes


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article