Transcript#
This transcript was generated automatically and may contain errors.
So today I wanted to talk about three ways that you can ingest a CSV into Positron. Some people call this importing, some people call this loading. In any case, it's bringing in a CSV into your environment so then you can actually work with the data and do some analysis.
Here I have Positron open. I'm going to create a new folder through this welcome screen. I'll call it Ingest CSVs. I open up that folder and it's going to prompt me and ask if I want to create a Python environment. Positron does this using a tool called uv and I'm going to hit yes. In the file explorer, you notice that there is a new virtual environment that has been opened up.
From here I can actually install some packages. I'm going to open up my terminal and I'm going to run the uv command uv pip install pandas. Pandas is a very common Python library for manipulating data. And I'm also going to run uv pip install polars. Polars is a relatively newer tool for data manipulation in Python.
Loading a CSV preview in Positron
Here I have my CSV in my downloads folder and you can actually just drag and drop your CSV directly into your file explorer. Now it's popped up here, so that means it's available within the folder. Positron automatically shows me a preview of the data using the data explorer. So I can take a quick view of what's contained in the CSV. But if you look at the variables pane, you'll notice that it's not actually loaded into my session. This is just a preview.
So if I actually want to load the CSV, here are the three ways that we could do that.
Method 1: writing a script with Polars
So the first one is I'm going to hit command shift P to open up the command palette and I'm going to select Python, new Python file. And so of course the first way that we can import our data is writing a script. From here I can write import polars as PL. I run that line to import polars and then I could do something like dad equals PL dot read CSV, then the name of the file. And running that line, I can see that in my variables pane, the CSV is now loaded into my session.
Method 2: using the import dataset button
The second way I want to show you is through the import data button in Positron. If I click this button and select my CSV, it can actually provide the pandas or the R code for importing that data for reproducibility. But if I hit import, it also directly imports that CSV into my session.
Method 3: using AI with Posit Assistant
And the last way I want to show you that you can import data in Positron is you can use AI. So I'm going to open up Posit Assistant and then I can actually attach a file by clicking the file button and I'll select my CSV. And then I can tell Posit Assistant something like import this data set. Just to do something different, I'm going to say using R because in Positron we can switch between Python and R. And so it's going to go ahead and do that. I'll provide the R code for importing the CSV. And now instead of our Python environment, we're actually in an R environment and we have this data set, the CSV imported as a data frame.
Just to do something different, I'm going to say using R because in Positron we can switch between Python and R.
We hope that you try importing some data into Positron and let us know how it goes.