CSV Files in Xata!! Game Changer Of Databases is Here!!

Hero
4 min readSep 9, 2023

--

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:

Tabular Data

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.
  1. First create an account in Xata IO for free
  2. Go to workspaces
  3. Create a Workspace and a Database by clicking on + Add Database
Give any name of your choice and click on create
  1. 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 must get the following output

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:

  1. Server less database platform powered by PostgreSQL
  2. 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
  3. Built in Playground where you can test your code
  4. Can import your custom data in seconds, no need to enter data in that old fashioned way!
  5. 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

Link of my portfolio

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

--

--

Hero

Full Stack Developer 🖥️ | Freelancer | Content Writer ✍ | Open Source Contributor 🤝| Loves to participate in hackathons♥|Always Open For Collabs & Client Work