<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CSV Archives - Codersee blog- Kotlin on the backend</title>
	<atom:link href="https://blog.codersee.com/tag/csv/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Kotlin &#38; Backend Tutorials - Learn Through Practice.</description>
	<lastBuildDate>Wed, 16 Apr 2025 04:50:29 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.codersee.com/wp-content/uploads/2025/04/cropped-codersee_logo_circle_2-32x32.png</url>
	<title>CSV Archives - Codersee blog- Kotlin on the backend</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Spring Boot CSV export &#8211; OpenCSV</title>
		<link>https://blog.codersee.com/spring-boot-csv-export-opencsv/</link>
					<comments>https://blog.codersee.com/spring-boot-csv-export-opencsv/#respond</comments>
		
		<dc:creator><![CDATA[Piotr]]></dc:creator>
		<pubDate>Mon, 26 Oct 2020 08:00:23 +0000</pubDate>
				<category><![CDATA[Spring]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[Spring Boot]]></category>
		<guid isPermaLink="false">http://codersee.com/?p=1552</guid>

					<description><![CDATA[<p>In this guide, I will teach you how to implement Spring Boot CSV export functionality using OpenCSV library and Kotlin.</p>
<p>The post <a href="https://blog.codersee.com/spring-boot-csv-export-opencsv/">Spring Boot CSV export &#8211; OpenCSV</a> appeared first on <a href="https://blog.codersee.com">Codersee blog- Kotlin on the backend</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2 class="article-heading-introduction">1. Introduction</h2>
<p>Last week, we&#8217;ve learned <a href="http://codersee.com/upload-csv-file-in-spring-boot-rest-api-with-kotlin-and-opencsv/" target="_blank" rel="noopener noreferrer">how to upload CSV files in Spring Boot REST API</a>. I&#8217;ve also mentioned, that conversion of CSV files is almost always an important part of any application.</p>
<p>In this guide, I will teach you how to implement <strong>Spring Boot CSV</strong> export functionality using <a href="http://opencsv.sourceforge.net/" target="_blank" rel="noopener noreferrer">OpenCSV</a> library and <strong>Kotlin</strong>.</p>
<h2 class="article-heading-main">2. Imports</h2>
<p>But before we will start coding, let&#8217;s add the necessary dependencies:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="groovy">    implementation("com.opencsv:opencsv:5.2")
    implementation("org.springframework.boot:spring-boot-starter-web")
</pre>
<p>Technically, we do not need <strong>web</strong> dependency to work with the CSV export, but in this tutorial, I will show you also the two ways in which we can create <strong>REST</strong> endpoints.</p>
<h2 class="article-heading-main">3. Create a User Class</h2>
<p>As the second step, let&#8217;s create a simple <strong>User</strong> class, which will be used later:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">class User(
    val id: Long,
    val email: String,
    val name: String
)
</pre>
<h2 class="article-heading-main">4. Create a User Service</h2>
<p>As the next step, let&#8217;s implement the <strong>UserService</strong> class:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">@Service
class UserService {
    fun findAllUsers() =
        listOf(
            User(1, "piotr@codersee.com", "Piotr"),
            User(2, "adam@codersee.com", "Adam"),
            User(3, "john@codersee.com", "John"),
            User(4, "karim@codersee.com", "Karim")
        )
}
</pre>
<p>As you can see, this simple class contains one function, which returns the immutable list of users. This implementation might be a good entry point for connecting to some database, or any other data source later.</p>
<h2 class="article-heading-main">5. Create REST Controller</h2>
<p>As the last step, before we will head to the CSV service, let&#8217;s implement the <strong>UserController</strong> class with two functions:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">@RestController
class UserController(
    private val csvService: CsvService
) {
    @PostMapping("/api/user/csv")
    fun getAllUsersCsvExport(response: HttpServletResponse) {
        csvService.exportUserListToCsv(response.writer)
    }

    @PostMapping("/api/user/csv/string")
    fun getAllUsersCsvExportWihStringWriter(): ResponseEntity {
        val result = csvService.exportUserListToCsvWithStringWriter()

        return ResponseEntity.ok(result.toString())
    }
}
</pre>
<p>In the first scenario, we will use the <strong>HttpServletResponse object</strong> provided by the servlet container to write our response using its <strong>PrintWriter</strong>. In the second scenario, we will use our own <strong>StringWriter</strong> object to return the <strong>CSV as a String</strong> (this method might be easily converted to send the export CSV as a part of some custom response object).</p>
<h2 class="article-heading-main">6. Create CSV Service</h2>
<p>After the above steps are done, we can start exploring the possibilities provided by the <strong>OpenCSV</strong> library. Let&#8217;s create the <strong>CsvService</strong> class and implement the <em><strong>prepareMappingStrategy</strong></em>:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">@Service
class CsvService(
    private val userService: UserService
) {
    private fun prepareMappingStrategy(): ColumnPositionMappingStrategy {
        val columns = arrayOf("id", "email", "name")

        val strategy = ColumnPositionMappingStrategy()
        strategy.setColumnMapping(*columns)
        strategy.type = User::class.java

        return strategy
    }
}
</pre>
<p>The <strong><em>prepareMappingStrategy</em></strong> function returns the <strong>ColumnPositionMappingStrategy</strong> object, which we will use for write operations later. Please notice, that the values of the <strong><em>columns</em></strong> array need to match the fields of the <em><strong>User </strong></em>class.</p>
<h3 class="article-heading-sub">6.1. Export Beans With Default Values</h3>
<p>Let&#8217;s start simply by exporting the list of all users using default values:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">fun exportUserListToCsv(writer: PrintWriter) {
    val users = userService.findAllUsers()

    val mappingStrategy = prepareMappingStrategy()
    val bean = StatefulBeanToCsvBuilder(writer)
        .withMappingStrategy(mappingStrategy)
        .build()

    bean.write(users)
}
</pre>
<p>As the result, we will get the list in the following format:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="raw">"1","piotr@codersee.com","Piotr"
"2","adam@codersee.com","Adam"
"3","john@codersee.com","John"
"4","karim@codersee.com","Karim"
</pre>
<h3 class="article-heading-sub">6.2. Export Beans Without the Quote Chars</h3>
<p>If for some reason, we would like to remove the quote character, we can use the <em><strong>withQuotechar</strong></em> function:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">fun exportUserListToCsvWithoutQuoteChar(writer: PrintWriter) {
    val users = userService.findAllUsers()

    val mappingStrategy = prepareMappingStrategy()
    val bean = StatefulBeanToCsvBuilder(writer)
        .withMappingStrategy(mappingStrategy)
        .withQuotechar(CSVWriter.NO_QUOTE_CHARACTER)
        .build()

    bean.write(users)
}
</pre>
<p>This time, our CSV export will be looking like this:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="raw">1,piotr@codersee.com,Piotr
2,adam@codersee.com,Adam
3,john@codersee.com,John
4,karim@codersee.com,Karim
</pre>
<h3 class="article-heading-sub">6.3. Export Beans With Custom Separator</h3>
<p>Although the <strong>CSV</strong> acronym stands for the <strong>comma-separated-values</strong>, we can easily set our custom separator using the <em><strong>withSeparator</strong></em> function:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">fun exportUserListToCsvCustomSeparator(writer: PrintWriter) {
    val users = userService.findAllUsers()

    val mappingStrategy = prepareMappingStrategy()
    val bean = StatefulBeanToCsvBuilder(writer)
        .withMappingStrategy(mappingStrategy)
        .withSeparator(';')
        .build()

    bean.write(users)
}
</pre>
<p>After this operation, our CSV export will have the following structure:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="raw">"1";"piotr@codersee.com";"Piotr"
"2";"adam@codersee.com";"Adam"
"3";"john@codersee.com";"John"
"4";"karim@codersee.com";"Karim"
</pre>
<h3 class="article-heading-sub">6.4. Export Beans With Custom Line Ending</h3>
<p>By default, the <strong><em>line feed </em></strong>is used as the line ending. To set our own one, we can use the <strong><em>withLineEnd</em></strong> function:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">fun exportUserListToCsvCustomLineEnd(writer: PrintWriter) {
    val users = userService.findAllUsers()

    val mappingStrategy = prepareMappingStrategy()
    val bean = StatefulBeanToCsvBuilder(writer)
        .withMappingStrategy(mappingStrategy)
        .withLineEnd("||\n")
        .build()

    bean.write(users)
    writer.close()
}
</pre>
<p>As you might have guessed, each line of the exported file will be ended with two vertical bars:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="raw">"1","piotr@codersee.com","Piotr"||
"2","adam@codersee.com","Adam"||
"3","john@codersee.com","John"||
"4","karim@codersee.com","Karim"||
</pre>
<h3 class="article-heading-sub">6.5. Export Beans With StringWriter</h3>
<p>In all of the above examples, we&#8217;ve been using the <strong>PrintWriter</strong> object obtained from the <strong>HttpServletResponse</strong>. As the last example, I want to show you how to export the data using created <strong>StringWriter</strong>:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">fun exportUserListToCsvWithStringWriter(): StringWriter {
    val users = userService.findAllUsers()

    val mappingStrategy = prepareMappingStrategy()
    val writer = StringWriter()
    val bean = StatefulBeanToCsvBuilder(writer)
        .withMappingStrategy(mappingStrategy)
        .build()
    bean.write(users)

    writer.close()
    return writer
}
</pre>
<p>To get the content of the CSV export, all we need to do is to invoke the <em><strong>toString</strong></em> method on the returned writer object (as we already did in our <strong>UserController</strong>).</p>
<h2 class="article-heading-main">7. Conclusion</h2>
<p>And that would be all for this article. We&#8217;ve learned how easy it is to create a <strong>Spring Boot CSV</strong> export functionality using <a href="http://opencsv.sourceforge.net/" target="_blank" rel="noopener noreferrer"><strong>OpenCSV</strong></a> library and <strong>Kotlin.</strong></p>
<p>I hope you really enjoyed this guide and that the Codersee really helps you to get a better understanding of programming. If you really think, that I am doing good work with my tutorials, would you be so kind and share our page with your friends? It&#8217;s the beginning of our journey and it is really hard to break through among many other pages offering programming tutorials. With your help, we would be able to build a really great community based on knowledge sharing and respect. Thank you in advance!</p>
<p>And of course, please find the source code in <a href="https://github.com/codersee-blog/kotlin-spring-boot-opencsv-export" target="_blank" rel="noopener noreferrer">this GitHub repository</a>.</p>
<p>The post <a href="https://blog.codersee.com/spring-boot-csv-export-opencsv/">Spring Boot CSV export &#8211; OpenCSV</a> appeared first on <a href="https://blog.codersee.com">Codersee blog- Kotlin on the backend</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.codersee.com/spring-boot-csv-export-opencsv/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Upload CSV Files in Spring Boot REST API with Kotlin and OpenCSV</title>
		<link>https://blog.codersee.com/upload-csv-file-in-spring-boot-rest-api-with-kotlin-and-opencsv/</link>
					<comments>https://blog.codersee.com/upload-csv-file-in-spring-boot-rest-api-with-kotlin-and-opencsv/#respond</comments>
		
		<dc:creator><![CDATA[Piotr]]></dc:creator>
		<pubDate>Mon, 19 Oct 2020 05:50:58 +0000</pubDate>
				<category><![CDATA[Spring]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[Spring Boot]]></category>
		<guid isPermaLink="false">http://codersee.com/?p=1528</guid>

					<description><![CDATA[<p>In this tutorial, we will learn how to upload CSV files in Spring Boot REST API with Kotlin programming language and OpenCSV library.</p>
<p>The post <a href="https://blog.codersee.com/upload-csv-file-in-spring-boot-rest-api-with-kotlin-and-opencsv/">Upload CSV Files in Spring Boot REST API with Kotlin and OpenCSV</a> appeared first on <a href="https://blog.codersee.com">Codersee blog- Kotlin on the backend</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2 class="article-heading-introduction">1. Introduction</h2>
<p>A<strong> Comma Separated Values (CSV)</strong> files are delimited text files that use a comma to separate values (mostly, but other characters might be used as well). In such files, each line is a data record.</p>
<p>You might ask yourself, why should you even care about such files? Well, the answer is quite simple: these kinds of files are often used for exchanging the data between different systems. You can be sure, that most of the real-life applications, will require you to process CSV files.</p>
<p>In this pretty short tutorial, we will learn how to <strong>upload CSV files in Spring Boot REST API with Kotlin</strong> programming language and <strong>OpenCSV</strong> library.</p>
<h2 class="article-heading-main">2. Prepare Test Data</h2>
<p>Before we will jump to the <strong>Spring Boot</strong> project, let&#8217;s prepare the test data. I&#8217;ve already prepared them for you, so you can just download <a href="https://github.com/codersee-blog/kotlin-spring-boot-opencsv-upload/blob/master/src/main/resources/users.csv" target="_blank" rel="noopener noreferrer">this CSV file</a>. Below, you can see the structure of the data:</p>
<p><img fetchpriority="high" decoding="async" class="alignnone wp-image-1537 size-full" src="http://blog.codersee.com/wp-content/uploads/2020/10/data_screenshot-1.png" alt="The image presents the screenshot of the test data" width="579" height="183" srcset="https://blog.codersee.com/wp-content/uploads/2020/10/data_screenshot-1.png 579w, https://blog.codersee.com/wp-content/uploads/2020/10/data_screenshot-1-300x95.png 300w" sizes="(max-width: 579px) 100vw, 579px" /></p>
<p>Please notice, that this file matches the model of the data we will be using in our application (but I highly recommend for you to experiment a little and prepare your own data).</p>
<h2 class="article-heading-main">3. Imports</h2>
<p>With that being done, we can switch to our<strong> Spring Boot project</strong> and add the required dependencies:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="groovy">implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.opencsv:opencsv:5.2")
</pre>
<p>&nbsp;</p>
<p><a href="https://codersee.com/newsletter/"><img decoding="async" class="aligncenter wp-image-3002956 size-large" src="http://blog.codersee.com/wp-content/uploads/2022/05/join_newsletter-1024x576.png" alt="Image shows two ebooks people can get for free after joining newsletter" width="800" height="419" /></a></p>
<p>&nbsp;</p>
<h2 class="article-heading-main">4. Prepare Models</h2>
<h3 class="article-heading-sub">4.1. Create a User Class</h3>
<p>As the first step, let&#8217;s prepare the <strong>User</strong> class structure, which will represent the row of the <strong>CSV file</strong>:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">data class User(
    var id: Long? = null,
    var firstName: String? = null,
    var lastName: String? = null,
    var email: String? = null,
    var phoneNumber: String? = null,
    var age: Int? = null
)
</pre>
<h3 class="article-heading-sub">4.2. Create Custom Exceptions</h3>
<p>This step of the tutorial <em>is not necessary</em>. However, I wanted to share a pretty cool <strong>Spring</strong> feature, which allows us to mark the exception class with the status code we want to return. Let&#8217;s implement two classes for later:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">@ResponseStatus(HttpStatus.BAD_REQUEST)
class BadRequestException(msg: String) : RuntimeException(msg)

@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
class CsvImportException(msg: String) : RuntimeException(msg)
</pre>
<p>As you probably guessed, the <strong>BadRequestException</strong> will return the<strong> 400 Bad Request</strong> status code to the user, while the <strong>CsvImportException</strong> will return the <strong>500 Internal Server Error</strong>.</p>
<h2 class="article-heading-main">5. Implement CSV Service</h2>
<p>As the next step, let&#8217;s implement the <strong>CSV service</strong>. Let&#8217;s start by adding a validator function:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">@Service
class CsvService {
    private fun throwIfFileEmpty(file: MultipartFile) {
        if (file.isEmpty)
            throw BadRequestException("Empty file")
    }
}
</pre>
<p>This simple function will throw the <strong>BadRequestException</strong> if the file <strong>has no content</strong> or <strong>no file has been chosen</strong> in the multipart form.</p>
<p>Nextly, let&#8217;s add the <strong>createCSVToBean</strong> function:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">private fun createCSVToBean(fileReader: BufferedReader?): CsvToBean&lt;User&gt; =
    CsvToBeanBuilder&lt;User&gt;(fileReader)
        .withType(User::class.java)
        .withIgnoreLeadingWhiteSpace(true)
        .build()
</pre>
<p>We used here the <strong>CsvToBeanBuilder</strong> class to configure the <strong>CsvToBean</strong> which will be used to <strong>convert the CSV data to objects</strong>. If you would like to know, what else can be configured with it, I highly recommend checking it&#8217;s documentation <a href="http://opencsv.sourceforge.net/apidocs/com/opencsv/bean/CsvToBeanBuilder.html" target="_blank" rel="noopener noreferrer">here</a>.</p>
<p>The last helper function we will create is the <strong>closeFileReader</strong>:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">private fun closeFileReader(fileReader: BufferedReader?) {
    try {
        fileReader!!.close()
    } catch (ex: IOException) {
        throw CsvImportException("Error during csv import")
    }
}
</pre>
<p>All it does is closing the stream and releasing any system resources associated with it.</p>
<p>Finally, we can combine together all of the above and create the <strong>uploadCsvFile</strong> function:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">fun uploadCsvFile(file: MultipartFile): List {
    throwIfFileEmpty(file)
    var fileReader: BufferedReader? = null

    try {
        fileReader = BufferedReader(InputStreamReader(file.inputStream))
        val csvToBean = createCSVToBean(fileReader)

        return csvToBean.parse()
    } catch (ex: Exception) {
        throw CsvImportException("Error during csv import")
    } finally {
        closeFileReader(fileReader)
    }
}
</pre>
<h2 class="article-heading-main">6. Configure CSV and Bean Binding</h2>
<p>Before we will be able to parse our CSV input file, we need to specify how do we want the data to be bound to our bean. We can do that in several ways, but in this tutorial, I will show you the two most frequently used.</p>
<h3 class="article-heading-sub">6.1. Bind With @CsvBindByName</h3>
<p>This annotation specifies a binding between a <em><strong>column name</strong></em> of the CSV input and a <em><strong>field in a bean</strong></em>.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">data class User(
    @CsvBindByName(column = "Id")
    var id: Long? = null,
    @CsvBindByName(column = "First Name")
    var firstName: String? = null,
    @CsvBindByName(column = "Last Name")
    var lastName: String? = null,
    @CsvBindByName(column = "Email")
    var email: String? = null,
    @CsvBindByName(column = "Phone number")
    var phoneNumber: String? = null,
    @CsvBindByName(column = "Age")
    var age: Int? = null
)
</pre>
<p>Please notice here, that the name of the column must <strong>be identical</strong> to the name of the field.</p>
<h3 class="article-heading-sub">6.2. Bind With @CsvBindByPosition</h3>
<p>Another way is to bind the data <strong>based on a column number</strong> of the CSV input:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">data class UserWithCsvBindByPosition(
    @CsvBindByPosition(position = 0)
    var id: Long? = null,
    @CsvBindByPosition(position = 1)
    var firstName: String? = null,
    @CsvBindByPosition(position = 2)
    var lastName: String? = null,
    @CsvBindByPosition(position = 3)
    var email: String? = null,
    @CsvBindByPosition(position = 4)
    var phoneNumber: String? = null,
    @CsvBindByPosition(position = 5)
    var age: Int? = null
)
</pre>
<p>But that&#8217;s not all we need to do here. The first line in our CSV file contains headers. In this scenario, we have to configure our <strong>CsvToBean</strong> to skip it by adding the <strong>withSkipLines</strong> invocation:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">private fun createCSVToBean(fileReader: BufferedReader?): CsvToBean =
    CsvToBeanBuilder(fileReader)
        .withType(User::class.java)
        .withSkipLines(1)
        .withIgnoreLeadingWhiteSpace(true)
        .build()
</pre>
<h2 class="article-heading-main">7. Create REST Controller</h2>
<p>As the last step, we need to configure the <strong>REST endpoint</strong>. Let&#8217;s create the <strong>CsvController</strong> and add the <strong>uploadCsvFile</strong> function to it:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="kotlin">@RestController
@RequestMapping("/api/csv")
class CsvController(
    private val csvService: CsvService
) {
    @PostMapping
    fun uploadCsvFile(
        @RequestParam("file") file: MultipartFile
    ): ResponseEntity&lt;List&gt; {
        val importedEntries = csvService.uploadCsvFile(file)

        return ResponseEntity.ok(importedEntries)
    }
}
</pre>
<p>A <strong>MultipartFile</strong> parameter is a representation of an uploaded file received in a multipart request.</p>
<h2 class="article-heading-main">8. Validation</h2>
<p>Finally, we can check if everything works fine. Let&#8217;s figure out, how we can do that with <strong>Postman</strong> or <strong>curl</strong> command.</p>
<h3 class="article-heading-sub">8.1. Testing Using Postman</h3>
<p>All we need to do in <strong>Postman</strong> is to specify the URL, select the form-data as the request body type, and add our file with the appropriate key:<br />
<img decoding="async" class="alignnone size-full wp-image-1533" src="http://blog.codersee.com/wp-content/uploads/2020/10/post-10-postman-validation.png" alt="The image shows the screenshot from Postman application testing." width="626" height="267" srcset="https://blog.codersee.com/wp-content/uploads/2020/10/post-10-postman-validation.png 626w, https://blog.codersee.com/wp-content/uploads/2020/10/post-10-postman-validation-300x128.png 300w" sizes="(max-width: 626px) 100vw, 626px" /></p>
<h3 class="article-heading-sub">8.2. POSTing CSV File with cURL</h3>
<p>If we would like to test with the command line, let&#8217;s specify the following:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="raw">curl -X POST -F 'file=@users.csv' http://localhost:8080/api/csv
</pre>
<h2 class="article-heading-main">8. Summary</h2>
<p>And that would be all for today. This time, we&#8217;ve learned how to <strong>upload CSV files in Spring Boot REST API with Kotlin</strong> programming language and <strong>OpenCSV</strong> library.</p>
<p>I hope you will find this article useful. If you would like to share some thoughts on that with me or ask additional questions, I encourage you to do so by our <a href="https://www.facebook.com/codersee/" target="_blank" rel="noopener noreferrer"><strong>fan page</strong></a>, <a href="https://www.facebook.com/groups/622361565094117" target="_blank" rel="noopener noreferrer"><strong>group</strong></a>, or <strong><a href="https://codersee.com/contact/" target="_blank" rel="noopener noreferrer">contact</a> </strong>form.</p>
<p>For the source code, please visit <a href="https://github.com/codersee-blog/kotlin-spring-boot-opencsv-upload" target="_blank" rel="noopener noreferrer">this GitHub project</a>.</p>
<p>The post <a href="https://blog.codersee.com/upload-csv-file-in-spring-boot-rest-api-with-kotlin-and-opencsv/">Upload CSV Files in Spring Boot REST API with Kotlin and OpenCSV</a> appeared first on <a href="https://blog.codersee.com">Codersee blog- Kotlin on the backend</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.codersee.com/upload-csv-file-in-spring-boot-rest-api-with-kotlin-and-opencsv/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: blog.codersee.com @ 2026-05-13 13:08:59 by W3 Total Cache
-->