CONVERSIKIT
CONVERSIKIT is a versatile JavaScript library that provides a wide range of functions for converting and transforming text and data. Whether you need to change letter casing, convert between different data formats, apply camel case formatting, or handle CSV and TSV data, CONVERSIKIT has you covered.
Overview
CONVERSIKIT is designed to simplify data processing and text manipulation tasks in your JavaScript projects. It offers a set of easy-to-use functions, each tailored for specific data transformation needs.
Features
-
Case Conversion: Easily convert text to uppercase, lowercase, or capitalize case to meet your formatting requirements.
-
JSON and Array Conversion: Seamlessly switch between JSON and array data structures, making data interchange more convenient.
-
Camel Case Formatting: Convert strings to camel case, a common practice in JavaScript coding.
-
CSV and TSV Handling: Efficiently work with CSV (Comma-Separated Values) and TSV (Tab-Separated Values) data, both for reading and writing.
Functions
toConvertUpperCase(string)
- Converts all letters in the input string to uppercase.
toConvertLowerCase(string)
- Converts all letters in the input string to lowercase.
toConvertCapitalizeCase(string)
- Converts the input string into capitalize case.
toConvertArrayJson(array)
- Converts an array to JSON format.
toConvertJsonArray(array)
- Converts JSON data to an array format.
toConvertCamelCase(string)
- Converts a string into camel case.
toConvertCSVFile(data, fileName)
- Converts an array of JSON data into a CSV file.
toConvertCSVToJson(path)
- Converts a CSV file into JSON format.
toConvertTSVToJson(path)
- Converts a TSV (Tab-Separated Values) file into JSON format.
This function is designed to take a path to a TSV file as its parameter and convert the content of the TSV file into a JSON format. It reads the TSV file, parses its contents, and returns the data as an array of JSON objects.
toConvertExcelToCSV('your_excel_file.xlsx')
-
Here you convert a excel file in to csv format where its take all sheet, which is present in your excel file.
-
path (String): The file path to the Excel file you want to convert to JSON.
Examples
const conversikit = require("conversikit");
async function example() {
const data = await conversikit.toConvertUpperCase("thank you my man");
const data1 = await conversikit.toConvertLowerCase("thank you my Man");
const data2 = await conversikit.toConvertCapitalizeCase("thank you my Man");
console.log(data);
console.log(data1);
console.log(data2);
}
example();
Convert Array to JSON
const conversikit = require("conversikit");
const data = [
"name",
"Ankit",
"roll",
"10",
];
const jsonData = await conversikit.toConvertArrayJson(data);
console.log("Result =", jsonData);
Output:
Result = {
name: "Ankit",
roll: "10",
};
Note: If duplicate keys are present in the array, they will be handled gracefully.
Convert String into Camel Case
const conversikit = require("conversikit");
const data = "thank you";
const data1 = "";
const data2 = "thank";
const data3 = "we are programmer";
const result = await conversikit.toConvertCamelCase(data);
const result1 = await conversikit.toConvertCamelCase(data1);
const result2 = await conversikit.toConvertCamelCase(data2);
const result3 = await conversikit.toConvertCamelCase(data3);
Convert Array JSON Data to CSV File
const conversikit = require("conversikit");
const data = [
{ name: "test1", age: 10 },
{ name: "test2", age: 30 },
];
const filename = "example.csv";
await conversikit.toConvertCSVFile(data, filename);
Convert CSV to JSON
const conversikit = require("conversikit");
const data = await conversikit.toConvertCSVToJson("give your file path name");
Output:
Result = [
{ name: 1, age: 10, dob: "12-08-1997" },
{ name: "thank", age: 90, dob: "12-09-1995" },
];
Convert TSV to JSON
const conversikit = require("conversikit");
const data = await conversikit.toConvertTSVToJson("give your file path name");
Name Age City
John 30 New York
Alice 25 Los Angeles
Bob 35 Chicago
Output:
Result = [
{
"Name": "John",
"Age": "30",
"City": "New York"
},
{
"Name": "Alice",
"Age": "25",
"City": "Los Angeles"
},
{
"Name": "Bob",
"Age": "35",
"City": "Chicago"
}
];
Excel to CSV Converter
This Node.js script allows you to convert an Excel file (.xlsx
) into one or more CSV files, one for each sheet in the Excel workbook.
Prerequisites
Make sure you have the xlsx
library installed. You can install it using npm:
npm install xlsx
Usage
- Replace 'your_excel_file.xlsx' with the path to your Excel file.
- Run the script.
The script will read the Excel file and save each sheet as a separate CSV file.
Example
To convert an Excel file to CSV, you can call the toConvertExcelToCSV function with the path to your Excel file:
await toConvertExcelToCSV('your_excel_file.xlsx');
Author
Arun Pradhan.
Other
Feel free to reach out for questions, feedback, or contributions.
THANK YOU FOR USING CONVERSIKIT!