# Retrieve data from files [Kotlin DataFrame library](https://kotlin.github.io/dataframe/home.html) enables you to work with both non-structured and structured data. For data transformations, you can use such methods as [.add()](https://kotlin.github.io/dataframe/adddf.html), [.split()](https://kotlin.github.io/dataframe/split.html), [.convert()](https://kotlin.github.io/dataframe/convert.html), and [.parse()](https://kotlin.github.io/dataframe/parse.html). Additionally, this toolset enables the retrieval and manipulation of data from various structured file formats, including CSV, JSON, XLS, Parquet, and Apache Arrow. See all supported formats in the [DataFrame documentation](https://kotlin.github.io/dataframe/data-sources.html). In this guide, you can learn how to retrieve, refine, and handle data through multiple examples. ## Before you start Note: Starting with IntelliJ IDEA 2026.2, Kotlin Notebook will no longer be bundled with the IDE or officially supported by JetBrains. The source code will remain available on [GitHub](https://github.com/Kotlin/kotlin-notebook). Learn more in the [blog post](https://blog.jetbrains.com/idea/2026/06/kotlin-notebook-sunset/). To follow this tutorial: 1. Select File | New | Kotlin Notebook. 2. Import Kotlin DataFrame: ```KOTLIN %use dataframe ``` Run the code cell with the `%use dataframe` line before any other code cells to make sure the DataFrame library and its APIs are available in the notebook. To follow the tutorial, you can also use DataFrame as a [Gradle](https://kotlin.github.io/dataframe/setupgradle.html) or [Maven](https://kotlin.github.io/dataframe/setupmaven.html) dependency. ## Retrieve data To retrieve data from a file, use the `DataFrame.read()` function: ```KOTLIN val movies = DataFrame.read("movies.csv") ``` The `DataFrame.read()` function detects the input format based on the file extension and content. You can also pass additional arguments to control how the DataFrame library reads the input data. For example, the following code specifies a custom delimiter (`;`) for a CSV file: ```KOTLIN val movies = DataFrame.read("movies.csv", delimiter = ';') ``` Tip: For a comprehensive overview of additional file formats and a variety of read functions, see the [Kotlin DataFrame library documentation](https://kotlin.github.io/dataframe/read.html). ## Display data Once you have the data, you can display it. The easiest way is to store your data in a variable and then return it: ```KOTLIN val jsonDf = DataFrame.read("jsonFile.json") jsonDf ``` This code displays the data from your file as an interactive table: ![Display data](images/display-data.png) You can use this view to inspect values, check column names, and easily understand the state of your dataset. ## Inspect data structure To gain insights into the structure or schema of your data, use the [.schema()](https://kotlin.github.io/dataframe/schema.html) function on your DataFrame variable. For example, run `jsonDf.schema()` to list the type of each column in your JSON dataset: ![Schema example](images/schema-data-analysis.png) You can also use the autocompletion feature. It allows you to quickly access and manipulate the properties of your DataFrame. After loading your data, simply type the DataFrame variable followed by a period (`.`) to see a list of available columns and their types. ![Available properties](images/auto-completion-data-analysis.png) ## Refine data Kotlin DataFrame provides various operations for refining your dataset. For example, [grouping](https://kotlin.github.io/dataframe/group.html), [filtering](https://kotlin.github.io/dataframe/filter.html), [updating](https://kotlin.github.io/dataframe/update.html), or [adding new columns](https://kotlin.github.io/dataframe/add.html). These functions are essential for data analysis, allowing you to organize, clean, and transform your data effectively. For example, let's look at the `movies.csv` dataset. It stores movie titles and release years in the same cell. The goal is to refine this dataset for easier analysis: 1. Load the data Load the file into a `DataFrame` using the `.read()` function: ```KOTLIN val movies = DataFrame.read("movies.csv") ``` 2. Add a column To extract the release year from the `title` column, add a new `year` column: ```KOTLIN val moviesWithYear = movies .add("year") { "\\d{4}".toRegex() .findAll(title) .lastOrNull() ?.value ?.toInt() ?: -1 } moviesWithYear ``` 3. Update values To remove the release year from the movie title, update the `title` column: ```KOTLIN val moviesTitle = moviesWithYear .update("title") { "\\s*\\(\\d{4}\\)\\s*$".toRegex().replace(title, "") } moviesTitle ``` The code keeps the movie titles in one column and moves the release years into another column. 4. Filter rows To focus on specific data, use the `.filter()` function. For example, to keep only the movies released after 1986, run: ```KOTLIN val newMovies = moviesTitle.filter { year >= 1996 } newMovies ``` 5. Remove column To remove a column that you do not need, use the `.remove()` function: ```KOTLIN val refinedMovies = newMovies.remove { movieID } refinedMovies ``` For comparison, here is the dataset before refinement: ![Original dataset](images/original-dataset.png) The dataset after refinement: ![Data refinement result](images/refined-data.png) Tip: For additional use cases and detailed examples, see [Examples of Kotlin Dataframe](https://github.com/Kotlin/dataframe/tree/master/examples). ## Export data After refining the data, you can easily export it. You can utilize a variety of [.write()](https://kotlin.github.io/dataframe/write.html) functions for this purpose. It supports saving in multiple formats, including CSV, JSON, XLS, XLSX, Apache Arrow, and even HTML tables. See all supported formats in the [DataFrame documentation](https://kotlin.github.io/dataframe/data-sources.html). This can be particularly useful for sharing your findings, creating reports, or making your data available for further analysis. For example, let's save the result as: * JSON file using the [.writeJson()](https://kotlin.github.io/dataframe/write.html#writing-to-json) function: ```KOTLIN refinedMovies.writeJson("movies.json") ``` * CSV file using the [.writeCsv()](https://kotlin.github.io/dataframe/write.html#writing-to-csv) function: ```KOTLIN refinedMovies.writeCsv("movies.csv") ``` * [Apache Arrow files](https://kotlin.github.io/dataframe/write.html#writing-to-apache-arrow-formats) using the `.writeArrorIPC()` and `.writeArrorFeather()` functions: ```KOTLIN refinedMovies.writeArrowIPC("movies.arrow") refinedMovies.writeArrowFeather("movies.feather") ``` You can also open a standalone HTML table in your browser with the [.toStandaloneHTML()](https://kotlin.github.io/dataframe/tohtml.html) function: ```KOTLIN refinedMoviesDf .toStandaloneHTML(DisplayConfiguration(rowsLimit = null)) .openInBrowser() ``` ## What's next * Explore data visualization using the [Kandy library](https://kotlin.github.io/kandy/examples.html) * Find additional information about data visualization in [Data visualization with Kandy](data-analysis-visualization.html) * For an extensive overview of tools and resources available for data science and analysis in Kotlin, see [Kotlin and Java libraries for data analysis](data-analysis-libraries.html)