tsv to csv conversion

TSV to CSV conversion using Java REST API.

Converting TSV (Tab-Separated Values) to CSV (Comma-Separated Values) is a crucial task for ensuring data compatibility and usability across diverse applications and systems. While TSV is commonly used for tabular data, many tools, platforms, and software systems favor the more universally supported CSV format. By converting TSV to CSV, you enhance data interoperability, simplify processing, and ensure seamless integration with popular applications like spreadsheets, databases, and web services.

API for TSV to CSV Conversion

Converting TSV to CSV using Java REST API with Aspose.Cells Cloud SDK for Java is a simple and efficient solution for handling data transformation. This SDK allows developers to easily convert tabular data formats, such as TSV, into the widely supported CSV format, ensuring compatibility with spreadsheets, databases, and other analytical tools. Its RESTful architecture makes it easy to integrate into applications across platforms, while cloud scalability ensures high performance for large-scale tasks.

Installation

Please add the following details to pom.xml file of maven build project.

<repositories>
    <repository>
        <id>AsposeJavaAPI</id>
        <name>Aspose Java API</name>
        <url>https://repository.aspose.cloud/repo/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-cells-cloud</artifactId>
        <version>24.9</version>
    </dependency>
</dependencies>

Now, we need to obtain our client credentials from cloud dashboard. If you do not have an existing account, simply create a free account by following the instructions specified in the quick start article.

Convert TSV to CSV in Java

The following section provides the details on how to convert a TSV to CSV format using Java code snippet:

CellsApi api = new CellsApi(clientId,clientSecret);

Create an instance of CellsApi while providing client credentials as input arguments.

api.uploadFile("input.tsv", file, "internal");

Upload the source TSV to the cloud storage using uploadFile(…) method.

File response = api.cellsWorkbookGetWorkbook(name,  password,format, 
			isAutoFit, onlySaveTable, null,"internal",  "myResultant.csv","internal", null);

Finally, call the method cellsWorkbookGetWorkbook(…) to initiate the conversion operation.

tsv to csv conversion

A preview of TSV to CSV conversion.

The sample files used in the above example can be downloaded from input.tsv and resultantFile.csv.

TSV to CSV Conversion using cURL Commands

The conversion of TSV to CSV using Aspose.Cells Cloud and cURL commands is a straightforward and effective approach for automating data transformations. This method allows you to upload a TSV file to Aspose.Cells Cloud, specify CSV as the desired output format, and download the converted file—all through simple RESTful API calls using cURL. It’s an ideal choice for automating repetitive tasks, streamlining workflows, and enabling seamless integration into broader applications and processes.

The first step in this method is to generate a JWT access token using the following command:

curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=XXXXXXX-b195-426c-85f7-XXXXXXXX&client_secret=XXXXXXXXXXXXXXXXXXXXXXXXX" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Now that we have the JWT token, we need to execute the following command and convert TSV to CSV format.

curl -v "https://api.aspose.cloud/v3.0/cells/{sourceFile}/SaveAs?newfilename={myResultant}&isAutoFitRows=false&isAutoFitColumns=false&checkExcelRestriction=false" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{ \"SaveFormat\": \"json\",}"

If you have a preference to save the resultant CSV on local drive, please try executing the following command:

curl -v "https://api.aspose.cloud/v3.0/cells/resultantFile.json?format=CSV&isAutoFit=false&onlySaveTable=false" \
-X GET \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-o "output.json"

Replace sourceFile with the name of input TSV file (available in the cloud storage), myResultant with the name of resultant CSV file and accessToken with JWT access token generated above.

Free TSV to CSV Converter

We also recommend you to try using our free TSV to CSV Converter. This lightweight and super-efficient web-App is developed on top of Aspose.Cells Cloud and enables you to experience the amazing capabilities of REST API.

tsv to csv converter

A preview of TSV to CSV converter App.

Conclusion

In conclusion, whether you choose to convert TSV to CSV using the Aspose.Cells Cloud SDK for Java or through cURL commands, both approaches provide reliable and efficient solutions for transforming tabular data. Nonetheless, by leveraging Aspose.Cells Cloud, you can simplify your data workflows, save time, and enhance productivity, making it an invaluable tool for modern data transformation needs.

We highly recommend visiting the following links to learn more about: