What are CSV Files?
CSV (comma-separated values) is a simple file format used to store tabular data, such as a spreadsheet or database. Files in the CSV format can be imported to and exported from programs that store data in tables.What is Xata?
Server less database platform powered by PostgreSQL
Modern applications are complex. They make the data part easy with the functionality your application needs to evolve and scale.
Example of CSV:
How to create a CSV File?
To create a CSV file with a text editor such as Notepad and open a new file. Then enter the text data you want the file to contain, separating each value with a comma and each row with a new line.
Save this file with the extension .csv
Features supported by Xata IO in importing CSV Files
- There is no well defined standard and lots of variations. For example there are different separators and header can be present or missing.
- We wanted to support large files (millions of rows and GBs of data), meaning rows need to be streamed and processed in batches, while ensuring there are no memory leaks in the browser.
- Importing with the correct data types is important. For example, a column might use numbers in the first few records, but then have a string value further in the file.
- Treating and reporting errors in a user-friendly way is important. No on wants to attempt importing millions of rows only to be hit with an unhelpful error.
- First create an account in Xata IO for free
- Go to workspaces
- Create a Workspace and a Database by clicking on
+ Add Database
- Go to your Database click on
Add a table
Click on Import a CSV File
Drag the file or click on Browse your Desktop
You can have sample CSV files from this repo
Choose the .csv
file from your workspace.
After that, click on Begin Import
It will complete the import and then click on Go to Table
You can do the above operation through terminal too
Run the following commands:
curl --create-dirs -o seed/test.csv https://media.githubusercontent.com/media/datablist/sample-csv-files/main/files/people/people-100.csv
Before running the next command, you need to do this first:
1. Install the Xata CLI (Command Line Interface) globally
2. Login your account
npm install -g @xata.io/cli
xata auth login
Next, import the CSV:
xata import csv seed/test.csv --table Test --create
The same output should be produced in both the cases
Benefits of using Xata as a Database against other databases:
- Server less database platform powered by PostgreSQL
- You can create branches and work! Yes you heard that right, you can create sample branches and work together just like used to work in GitHub
- Built in Playground where you can test your code
- Can import your custom data in seconds, no need to enter data in that old fashioned way!
- Can make search functionality in a second
Much more coming soon!!
Till that have a look at the Xata Docs for more such interesting things !
I am a freelancer & content-writer
Follow me on medium for more such superb blogs :)
Any doubts?
Contact me:
Discord: hero.xyz
Twitter
I hope you’ve enjoyed reading it.
Will be back soon with another blog, to get updated with my blogs follow me on medium or subscribe to the newsletter.
Till that time, have a nice day ahead, and always keep smiling. :)
Thank You,
Hero