Questions tagged [csv]

CSV, which stands for Comma-Separated Values but can also be called Character-Separated Values, is a widely used format for storing tabular data in plain text. It acts as a "flat file database" or resembles a spreadsheet-style layout. Essential to its structure is the separation of fields by a designated character like a comma, tab, or similar options. Each row is typically indicated by newline characters. This versatile format caters to various delimited file types, such as tab delimited (TSV), and proves valuable for managing and organizing data efficiently.

What is the best way to display CSV file data on an HTML webpage?

I am encountering an issue with displaying the data from my CSV file in an HTML page. Here is a snippet of my CSV file: number:Int,english,french,german 1,one,un,eins 2,two,deux,zwei 3,three,trois,drei 4,four,quattre,four 5,five,cinque,fuenf 6,six,six,sec ...

Search for a specific value within a CSV document

I'm having trouble retrieving a specific value from a CSV file based on certain criteria within a function. Although my program successfully fetches all the values, it fails to return the one linked to the input I provided. Any assistance would be greatly ...

What is the best way to change multiple arrays of strings within a JSON file into CSV format using Python?

How can Python be used to convert a nested JSON with multiple arrays into a CSV tabular structure? View the complete JSON file here CODE: import json import csv f = open('cost_drilldown_data.json') data = json.load(f) s=csv.writer(open(' ...

Do we need to include a Byte Order Mark in this situation?

When creating a csv file using PHP for download in a browser, should I include the byte order mark bytes at the beginning to account for different target systems such as Mac, Unix, Windows, etc? ...

Attempting to transform a JSON file or string into a CSV format results in an unpopulated CSV file

So I have this task of converting a JSON file to a CSV file. I'm using the Google Sheets API to export the JSON file, but when I try to convert it, either with the file location or as a string, I always get a null pointer exception or an empty CSV file. T ...

Leveraging PapaParse for CSV file parsing in a React application with JavaScript

I am encountering an issue with reading a CSV file in the same directory as my React app using Javascript and Papaparse for parsing. Below is the code snippet: Papa.parse("./headlines.csv", { download: true, complete: function(results, f ...

Error message encountered while trying to read and convert OHLC data using pandas in Python: AttributeError - 'int' object does not support attribute 'to_pydatetime'

I'm attempting to import OHLCV data from a .CSV file into a Pandas dataframe using the pandas.read_csv() function, but I keep encountering the same error and I can't determine the cause. AttributeError: 'int' object has no attribute 'to_pydatetime' It se ...

A guide to Java Selenium testing: Extracting data from a CSV file to input into a TestNG test

As I near completion on my project, I have encountered a hurdle in reading specific rows or columns from a CSV file. Currently, my methods and code are functioning correctly. However, the challenge lies in extracting particular data from the CSV file struc ...

Saving an array in a Mongodb collection using a Mongoose schema

I recently delved into the world of Mongoose and faced some challenges while attempting to import a Kaggle csv file for practice into a MongoDB database. The specific csv file I was working with can be found at . My goal was to store the values provided a ...

Combining data from two CSV files to create a JSON file

My goal is to merge two CSV files and convert the data into JSON format. The challenge lies in the fact that the same column values in both files may not correspond uniquely across rows, as demonstrated here: gpo_full.csv: Date hearing_sub_type ...

Saving a Python list to a CSV file will empty the list

I'm currently experimenting with lists, the enumerate() method, and CSV files. In my process, I am using the writerows() method to store an enumerate object in a .csv file. However, once the writing is complete, the list/enumerate object ends up empt ...

Exploring data in Python: Reading CSV files column-wise

I have a python program that needs to manipulate data from a csv file. The file contains rows of varying lengths, like the example below: 1,B,T,P,B,B,B,P,P,P,T,P,P,P,P,T,B,P,P,B,P,P,B,B,P,P 2,T,P,B,P,B,B,P,P,B,B,T,P,B,B,T,P,P,B,B,B,B,P,T,B,T,B,B,B,P 3,P,P ...

Guide on transferring CSV files from a different server to my server via an FTP connection

Hey there, I'm trying to figure out how to download CSV files from a folder located on the root directory of one server to another server using FTP connection. I've included the code below, but unfortunately it's not working for me. The FTP connection is ...

How to Store Values from a ReadStream in an Array

I'm currently attempting to use a stream and the async/await keywords with the fast-csv library in order to read a CSV file synchronously. Unfortunately, the function I've written doesn't seem to be producing the expected output. My assumpt ...

Exploring the process of reading multiple CSV files from various directories within Spark SQL

Having trouble reading multiple csv files from various folders from pyspark.sql import * spark = SparkSession .builder .appName("example") .config("spark.some.config.option") .getOrCreate() folders = List(& ...

Create several CSV files using MySQL and PHP

I've created a PHP script that is supposed to take an array and generate a CSV file for each element in the array. However, there seems to be an issue as it's not saving any files in the specified directory. Strangely, no errors are being returned either. ...

Adding a variety of variables to CSV document

Although this may seem similar to a previous question I asked, I have a Python code where I am analyzing the tone of text/html files and saving the output to a CSV file. My current issue is that I need to include two variables from the output, 'Tone_n ...

Is there a way to transform JSON into a CSV file using Python?

Is there a way to convert the logs in the JSON format shown below into a CSV file using Python? JSON Input (log.json): {"time":"14472","abc":"0","Def":[{"name":"C","value":77},{"name":"N","value":88}]} {"time":"1447","abc":"1","Def":[{"name":"C","valu ...

PHP script encountering a 404 error during execution (Approximately 45 seconds in)

I have a script located in a directory that does not have any set execution time limits (I routinely run scripts lasting hours from this location) along with a file within it. This file is called from an HTML form on a CodeIgniter view, which uploads a CSV ...

Converting object keys to arrays using jq

My goal is to transform a CSV file where the headers represent keys and the values in each column form a list. Here's an example of the CSV data: mpg cyl disp hp drat wt qsec vs am gear carb Mazda RX4 21 6 160 ...

The Angular service uses httpClient to fetch CSV data and then passes the data to the component in JSON format

I'm currently working on an Angular project where I am building a service to fetch CSV data from an API server and convert it to JSON before passing it to the component. Although the JSON data is successfully logged in the console by the service, the comp ...

Using JavaScript to transform JSON information into Excel format

I have tried various solutions to my problem, but none seem to fit my specific requirement. Let me walk you through what I have attempted. function JSONToCSVConvertor(JSONData, ReportTitle, ShowLabel) { //If JSONData is not an object then JSON.parse will ...

Avoid writing any duplicate values to a CSV file

I need help with converting a JSON file into a CSV file while avoiding duplicate values in the output. I want to include four columns in my CSV file without repeating any data. My approach involves storing variables in an array and writing them to a CSV f ...

Generating a CSV script that truncates values to 0 in PHP

After implementing a particular script, I encountered an issue where the 01523 values in my CSV file were being written as 1523. $file = fopen('demosaved.csv', 'w'); // save the column headers fputcsv($file, array('Column 1', 'Column 2', 'Column 3', 'Col ...

Uploading multiple files using PHP on an Ubuntu server

I have encountered an issue while attempting to upload multiple files in tsv and csv formats using PHP. The following HTML and PHP script has been included below. It successfully uploads files when executed with XAMPP on a Windows system. However, when I a ...

Converting CSV Data into JSON Format

I have a CSV file with data that is structured like this: After converting the CSV to JSON, the output looks something like this: { "Item1": "Data1", "Item2": "Data2", "Number1": 2209, "": 2210, ... and so on } However, I would like the JSON forma ...

What could be the reason for str_getcsv() removing quotation marks from fields?

The function str_getcsv() is specifically designed to operate on a single line of CSV text, not on multiple lines. I attempted to use it twice - once to separate multiple lines into an array and then again on each individual line. This approach was success ...

Trying to combine three columns in CSV and then updating the original CSV file

Here is some sample data: name1|name2|name3|name4|combined test|data|here|and test|information|343|AND ",3|record|343|and My coding solution: import csv import StringIO storedoutput = StringIO.StringIO() fields = ('name1', 'name2', 'name3', 'name4', ' ...

Find particular CSV data by using jQuery AJAX

Is it possible to utilize jQuery ajax for retrieving specific values from a CSV file when needed, like when a button is clicked? Imagine a CSV with the following data: country, capital, population, currency, france, paris, 65950000, euro, italy, rome, 59 ...

The storing of data in an HTML form input

Within my submission form, there are five distinct inputs that users can enter and submit. Currently, the entered data is being written to a .txt file successfully. Nevertheless, the objective is to organize and display the information in an easily readabl ...

Combining Two Tables Using jQuery

I am currently attempting to combine two tables into one using jQuery in the following manner: var table = document.createElement("table"); table.id = "mergedTable"; $("#mergedTable > tbody:last") .append($("#csvInfoTable2 > tbody").html()) ...

The presence of a comma within numerical values is leading to difficulties in parsing CSV

After attempting to read a csv file, I encountered the following error message: ParserError: Error tokenizing data. C error: Expected 1 fields in line 12, saw 2 I examined my csv file and pinpointed the issue to one of the numbers containing decimals sep ...

Discovering the URL of an img tag within a CSV file column containing numerous links and then cross-referencing that link with another CSV file

import csv # Open the Topic or Reply file for reading csvfile = open('rad.csv', newline='') reader = csv.reader(csvfile) csvfile1 = open('new.csv', newline='') reader1 = csv.reader(csvfile1) # Extract image sources f ...

Exploring DataFrames with interrows() and writing them out as CSV files with .to_csv:

I am using the following script to perform the following actions: Apply a function to a column in each row of a DataFrame Write the returns from that function into two new columns of a DataFrame Continuously write the DataFrame into a *.csv I am interes ...

How to add text to a CSV file with the help of fast-csv library

I've encountered an issue with my function that reads the accounts.csv file - it's currently unable to write to it. Every time I attempt to use fs.createWriteStream, it completely replaces the existing file instead of appending new data. Below is ...

Reversing the order: fopen followed by fgetcsv

Is there a way to modify this function so that only the last 20 lines of the document are displayed? $file = fopen("/tmp/$importedFile.csv","r"); while ($line = fgetcsv($file)) { $i++; $body_data['csv_preview'][] = $ ...

Guide on converting JSON array values into CSV format with JQ

I have a JSON file that stores information about different application clients along with their respective features: { "client-A": [ "feature-x" ], "client-B": [ "feature-x", "feature-y" ], "client-C": [ ...

Converting intricate JSON documents into .csv format

I have this JSON file containing a wealth of information about football players and I am trying to convert it into a .csv format. However, as a beginner in this field, I am facing some challenges! You can access the raw data file at: https://raw.githubuse ...

Saving Information to a Specific Location on the Client Side in a CSV File

I am currently working on a static application that uses Angular JS technology. My goal is to write data into a CSV file at a specific path in order for another API to read the data from that location. Despite searching extensively on the internet, I hav ...

Utilizing Node and Socket.io to transmit data periodically via websockets from a CSV file

I am relatively new to working with Node.js and Express.js. My goal is to set up a websocket server that can send CSV data at irregular intervals stored within the file itself, line by line. The structure of the CSV looks something like this: [timeout [ms] ...

Expanding query with additional JOIN and retrieving table column headings

I'm currently developing a function to convert data into CSV format, but I've hit a roadblock. At the moment, the function is fetching data from two tables and saving it to a CSV file in a single line for each order, including invoice and customer details ...

What is the best way to send a continuous stream of data in Express?

I've been attempting to configure an Express application to send the response as a stream. var Readable = require('stream').Readable; var rs = Readable(); app.get('/report', function(req,res) { res.statusCode = 200; res.setHeader('Content-ty ...

Tips on selectively crawling specific URLs from a CSV document using Python

I am working with a CSV file that contains various URLs with different domain extensions such as .com, .eu, .org, and more. My goal is to only crawl domains with the .nl extension by using the condition if '.nl' in row: in Python 2.7. from selen ...

Transform a nested JSON response from an API service into a CSV file using Python

Every attempt to save the output of an API response into a CSV file in an organized manner has been unsuccessful. Below is the script used to retrieve API data: import json import requests import csv # List of keywords to be checked keywords = open("/tes ...

When saving data to a CSV file in Python, the information is separated by commas, ensuring each character is properly recorded

Trying to read data from a CSV file and then write it to another one. However, the written data is separated by commas. Below is the code snippet: with open(filenameInput, 'r') as csvfile: dfi = pd.read_csv (filenameInput) dfi - dfi.ilo ...

Separate information into columns and save it as a two-dimensional array

Below is the data that I am working with: 49907 87063 42003 51519 21301 46100 97578 26010 52364 86618 25783 71775 1617 29096 2662 47428 74888 54550 17182 35976 86973 5323 ...... My goal is to iterate through it using for line in file. I would like to s ...

Python Script: Updating entries in CSV files

I have a Python script that reads CSV files and looks for a column called "PROD_NAME". If it finds a value in that column, I want it to replace the value with another one. The issue is that even though the script runs without errors and prints messages ind ...

Parsing a CSV file using Node.JS and Express on the server side

Basically, I have set up a form for users to upload a CSV file. <form action="/upload" method="POST" enctype="multipart/form-data"> <div class="custom-file"> <input type="file" class="custom-file-input" id="customFile" name="fi ...

What is the most efficient way to locate the next occurrence of a sub-buffer within a larger buffer, especially when you have a specified minimum distance to search

Summary: Although there are existing CSV file reading libraries for Node.js, I decided to create my own function to maximize optimization based on the specific properties of my CSV format. The file contains a variable entry-count-per line structure, which ...

ERROR: Automatic Python script for sending WhatsApp messages from a CSV file

from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.common.keys import Keys import csv import time caps = De ...

Enhancing JSON data by incorporating new key-value pairs

I need help converting a CSV file into a JSON file using C#. The issue I am facing is that the JSON generated contains only values without any keys. I want to convert it into a key => value format for better organization. Below is my current code: static ...

Is it necessary to scan through every column in a CSV file?

How can I efficiently read values from a CSV file and store them in separate lists based on columns, instead of rows? Currently, I am utilizing the seek() method to go back to the beginning of the file after looping through it once. Apart from using a Di ...

Python SQLite encounters difficulties when attempting to write data that contains an apostrophe within a string

Trying to write news headlines into a CSV file using Python's CSV module has raised an issue regarding apostrophes. For instance, when there is an apostrophe in a headline like 'What’s So Great About Snapchat Anyway?', an encode error occu ...

Utilizing Selenium to extract information from a data table

I am facing a challenge with extracting data from a paginated table using Selenium. Despite having code that can successfully retrieve data, it only grabs the first 50 results out of the entire table. I believe utilizing Selenium to iterate through all p ...

Attempting to construct a .csv file in PHP using an array

I need help converting the array below into a .csv file format, where the questions are placed in the first row, corresponding answers in the second row, and a Timestamp with the current time at the beginning. This is my attempt: <?php $qna = [ ...

PostgreSQL and Large CSV Files

Hey there, I'm in need of some help or advice. Currently, I am trying to manage a PostgreSQL database table using CSV files that contain over 500,000 records on average. Previously, I was able to use the Yii Framework to have an administrator handle t ...

Change a CSV string into a JSON array and assign it to a variable

I am working with JSON data that looks like this: [ { "Title": "PAGE A", "Users": "USRA" }, { "Title": "PAGE B", "Users": "USRA,USRB" } ] What is the most efficient method to convert the fields containing " ...

How to use jsZIP in angular to bundle several CSV files into a single zip folder for download

I have a code snippet below that demonstrates how to create data for a CSV file and download the CSV file in a zip folder: generateCSVfiles() { this.studentdata.forEach(function (student) { this.service.getStudentDetails(student.studentId).subsc ...

Is there a way to convert a JSONObject to a .csv file in GWT?

I'm brand new to GWT, so please forgive me if this is a basic question, but I can't seem to find the solution. I have a function that works fine and allows me to export a table as .xlsx file. Everything is going smoothly with this process. I am u ...

I wish to utilize csv.DictReader to seek out a specific string and then display the entire row that includes that string

Currently, I am facing some issues with a Python script I have created to assist me in handling a large .csv file. Within the main of my program, the user is prompted for an input and based on their response, a specific function is called. Here is an exam ...

Open and process a CSV file that contains empty lines

I have been working with analysis software that outputs multiple groups of results in a single CSV file, with each group separated by two empty lines. I want to be able to break down these results into separate groups for individual analysis. While explor ...

Steps for organizing directories in a CSV document

I need help with a script that lists directory names, file names, mp4 files, and empty directories in a CSV file. However, the output is being printed multiple times. Any assistance would be greatly appreciated. Thank you! import csv import os import sys ...

Secure PHP application thwarted by CSRF vulnerability

I have an issue with my controller action that generates a CSV file using the league/csv package. Whenever I submit the form, the file can be downloaded successfully. However, if I try to submit the request again, I receive a CSRF token failure due to th ...

Whenever I execute the script, it keeps publishing only the first row from the CSV file repeatedly

I need assistance with a script I have created to upload images to a website from a CSV file. However, each time I run the script, it only uploads the first row of data. Here is an excerpt from the script where I attempt to publish all images, descripti ...

Divide the extracted result of executing a command that handles an extremely massive compressed JSON file

Alright, let's kick off with the command line I'm currently using: curl --silent http://example.com/json.gz | pigz -dc | jq -r '[.name, .value] | @csv' > data.csv The CURL function will fetch a whopping 11.6 GB JSON file in compressed format from a sp ...

What is the best way to eliminate double quotes from multiple variables that combine to form a single string when exporting array variables to a csv file?

$fetchData = "SELECT * FROM members"; if (!$outputResult = mysqli_query($connection, $fetchData)) { exit(mysqli_error($connection)); } $usersList = array(); if (mysqli_num_rows($outputResult) > 0) { while ($rowsFetched = mysqli_fetch_assoc( ...

How can the date format in a CSV file be modified using Python?

Looking to convert the date format from 30-Jan-02 to 30.Jan.2002 when it appears in the second position within a CSV file using Python. I've made several attempts, but I'm getting caught up with compatibility between strings and bytes. import os ...

Accessing the value of a specific index in Python by reading a .txt file into an array

I have a large .txt data file presented in the following format (composed of all numbers): 0 1.2 2 3.1 20 21.2 22 23 30 31 32 33.01 The goal is to extract the values from the second column of this matrix and store them into a variable. I wrote the code b ...

Using jQuery to Convert CSV Data into an HTML Table

I've been exploring the incredible jquery.csvtotable.js plugin for converting csv files to html tables. One question that has been on my mind is how can I allow users to select a .csv file using a browse button that isn't a server-side control? ...

Expanding the Python CSV File Header

I need help finding a way to expand the header of a CSV file. I have the existing file header stored in a dictionary called dict1, and another dictionary named dict2 with keys that overlap with some in dict1. My goal is to add these overlapping keys to th ...

Import CSV data into MySQL database using PHP

Here is some PHP code: $handle = fopen($_FILES['filename']['tmp_name'], "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $import="INSERT into info(tazkira,gender,province,category,clin,training) values('$data[0]','$data[1]','$data[2]', ...

Access the CSV file using Office365 Excel via a scripting tool

Objective I want to open a CSV file using Office365's Excel without actually saving the file on the client's machine. Challenge The issue with saving raw data on the client's machine is that it leads to clutter with old Excel files accumulating over tim ...

Creating a JSON Array in Java with CDL.toJSONArray is not possible

My CSV data has the following structure: Name,Title,Class,Users Global D&A,W,clLevel,"ADMIN" Template Manager,X,clLevel,"G,ADMIN" Test Manager,W,clLevel,"G,ADMIN" I am attempting to convert this data to JSON using Java, but I have not been successful ...

Avoiding data in DataFrame from being replaced by csv file?

I have a python script that keeps overwriting the file with new data each time it runs. Can someone please advise me on how to prevent this from happening? Here's an example of what is currently happening: DF1 Table Count case ...

Converting a Dataframe or CSV to a JSON object array

Calling all python experts, I have a simple query that needs addressing. Take a look at the data below: 0 <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ed959691ab9f92d1dcc0c2">[email protected]</a> 1323916902 ...