Tag Archives: csv

Reading a CSV file into a 2d Array

Questions: I’ve been trying for days to learn how to create this code. It’s a homework example. Beginner Java Final Project. I’m about to rip out my hair, if you could guide me a little, I’d appreciate it. I can’t seem to figure out how to parse the csv file into a proper 2d array.… Read More »

Convert curl command to PHP for csv->Excel converter

Questions: Looks simple enough, but I can’t get this to work in PHP. curl -F files[]=@myfile.csv ‘https://www.rebasedata.com/api/v1/convert?outputFormat=xlsx&errorResponse=zip’ -o output.zip myfile.csv is my data file to convert. output.zip is the response containing the Excel file. It’s a csv to Excel converter service from this website https://www.rebasedata.com/convert-csv-to-excel-online Can anyone assist? Answers:

Reading CSV file using Apache Commons

Questions: I want to retrieve CSV file data from two files but in Nested format Here is three files containing server information and getting it into hashmap ipReader = new FileReader(SAMPLE_CSV_FILE_PATH); Iterable<CSVRecord> csvRecord = CSVFormat.DEFAULT .withFirstRecordAsHeader() .parse(ipReader); hardwareReader=new FileReader(SAMPLE_CSV_FILE_PATH01); Iterable<CSVRecord> csvRecord01 = CSVFormat.DEFAULT .withFirstRecordAsHeader() .parse(hardwareReader); utilizationReader=new FileReader(SAMPLE_CSV_FILE_PATH02); Iterable<CSVRecord> csvRecord02 = CSVFormat.DEFAULT .withFirstRecordAsHeader() .parse(utilizationReader); for(CSVRecord record:… Read More »

Data is not being fully exported from MySQL to CSV via PHP

Questions: Context: I’m working with the following stack: HTML/CSS, PHP, MySQL, and XAMPP to build a web app that stores and retrieves data entered to a form. Problem: I have two files (i) export.php and (ii) export_index.php. As you can see from the picture below the export_index.php file indexes the data and is a complete… Read More »

Static Header and Scrolling html table with d3 from csv

Questions: I am able to generate html table with d3 from csv (with conditional insertion of data in particular column) as below: <!DOCTYPE html> <head> <meta charset=”utf-8″> <script src=”https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js”></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } svg { width:100%; height: 100% } table { border-collapse: collapse; color: #333; background-color: #F7F6F3; } table thead { font-weight: bold; background-color:… Read More »

UTF-8 encoding CSV file

Questions: I have a CSV file, which using Excel to save as CSV UTF-8 encoded. I have my java code read the file as byte array then String result = new String(b, 0, b.length, “UTF-8″); But somehow the content “Montréal” becomes “Montr?al” when save to DB, what might be the problem? The environment is unix… Read More »

Line-Breaks on PHP fputcsv

Questions: I have this code. $value1 = ‘1’; $value2 = ‘2’; $value3 = ‘3’; $field = array (“field1”, “field2”, “field3”); $value = array ($value1, $value2, $value3); $list = array ($field, $value); $fp = fopen (‘file.csv’, ‘w’); foreach ($list as $fields) {    fputcsv ($fp, $fields); } fclose ($fp); But the result is like this: field1,field2,field3,1,2,3… Read More »

CSV to list of double arrays

Questions: I am trying to put the contents of a csv file into a list of double arrays. I have a List of type double[] and was wondering how to populate the arrays inside it. List <Double[]> lines = new ArrayList<Double[]>(); I previously added values to these arrays by doing: while ((thisLine = br.readLine()) !=… Read More »