I am using the Highcharts EXPORT-CSV plugin to export my chart series data to an Excel File. I have the following code which generates the .CSV file:
{
textKey: 'downloadCSV',
onclick: function () {
this.downloadCSV();
}
}
As a result, when I click the button an excel file is generated but the data is in the following format, everything is in one single column:
DateTime;"CIFQ: DRAYAGE"
04-30-2015;296
05-01-2015;270
05-29-2015;350
06-30-2015;350
07-30-2015;1833
12-14-2015;300
12-18-2015;350
Instead I'd like the data to be separated into two columns using the ';' delimiter. You can see that this is possible from the following jsfiddle if you click the dropdown and select 'Download CSV':
http://jsfiddle.net/highcharts/j4w4s0mw/
How do I get it so that excel separates my data into two separate columns as soon as the file opens?
I figured it out!
The website saying the following:
exporting.csv.itemDelimiter The item delimiter, defaults to ,. Use ;
for direct import to Excel.
But it turns out Excel uses ',' as a column delimiter.
Related
I have a CDE dashboard with multiple tables using the same column names:
I need to export to excel all the tables together into one excel sheet. I am using this on my button:
function exportTableData()
{
render_tblRosterTotals.queryState.exportData('xls', null, {filename:'Roster_totals.xls'});
render_tblClassTotals.queryState.exportData('xls', null, {filename:'Class_Totals.xls'});
}
which exports each table as a separate file but need them to both be combined into a single file on a single sheet.
I ended up creating a separate datasource that combined all the tables data into one query and then used that as the source for the button to export from.
I have a form with several fields (written in React).
By submitting the form, I want the values will be written to an existing Excel file (the Excel file is saved in OneDrive), i.e. each submit will add 1 row to the Excel sheet.
How can I do it?
You can use the Excel REST API to do this.
To add a row, first identify the endpoint for your Excel file, and send a POST request to a URL like
https://graph.microsoft.com/v1.0/me/drive/root:/{sheet-name}:/workbook/tables/Table1/rows/add
with a payload similar to:
{
'index': null,
'values': [
['col-1-value', 'col-2-value', ...]
]
}
Where index signifies the offset from the last created row.
I have a csv file which has the input in the below format (It has no headers as first row):
India,QA,1200,
India,QA1,1201,
India,QA2,1202,
USA,Dev1,5580,
USA,Dev2,5580,
AUS,Dev3,3300,
AUS,Dev4,3301,
I have configured the CSV Data Set Config component and have given the respective path and variable name details. Snapshot below:
from the command line argument, i will be invoking the Jmeter jmeter.bat -t C:\Users\Dev\Desktop\JI\testscript.jmx -JCountry=Indiawhich also has a parameter called JCountry=India.
Now, I have to use this value (India) and then search the csv file's first column and if it matches, I need to send only those particular rows matching to the country name given from the cmd to the script.
I thought of using If Controller but how can I check the csv files first row and when there is a match, send those details to the script.
The easiest option would be dynamically generating a CSV file with only India lines
Add setUp Thread Group to your Test Plan
Add Test Action sampler to the setUp Thread Group (this way you won't have an extra result in .jtl file)
Add JSR223 PreProcessor as a child of the Test Action Sampler
Put the following code into "Script" area:
String country = props.get('Country')
def originalCsvFile = new File('C:/Users/Dev/Desktop/JI/JVMDetails/Details.txt')
def countryCsvFile = new File('C:/Users/Dev/Desktop/JI/JVMDetails/Country.txt')
countryCsvFile.delete()
originalCsvFile.eachLine {line ->
if (line.startsWith(country)) {
countryCsvFile << line
countryCsvFile << System.getProperty('line.separator')
}
}
Configure your CSV Data Set Config to use C:\Users\Dev\Desktop\JI\JVMDetails\Country.txt as this file will have only those lines which start with what you have defined as Country property
More information:
Apache Groovy - Why and How You Should Use It
Groovy Goodness: Working with Files
You need to loop through CSV, see example or other examples.
As the second example use in while condition the variable from CSV: ${Country} .
Inside loop you need to add If Controller with condition to compare country variable against country property:
${__jexl3("${__P{Country}" == "${Country}")}
Checking this and using __jexl3 or __groovy function in Condition is advised for performances
I am currently trying to use the node module Oracledb to import a csv to my database. The database is connected correctly, as I can SELECT * FROM MYDB. But I cannot find a way to easily import a CSV to this database.
*note : I am currently using jsontoCSV and then fswrite to create the CSV. So if it is easier to write a SQL query to import a json to Oracle using Oracledb, that could also work.
Thank you.
I only have a rough management overview on oracle techniques. I would guess to use sqlloader or datapump (abbrevated dp) to read csv; perhaps using additionally (oracle) external tables (could be accessed via file system). It depends on your infrastructure.
The internet is full of examples. One main ressource for me is "ask tom" (use your fav. search engine with the words oracle ask tom kyte).
User SQL*Loader as mentioned.
create table
drop table mytab;
create table mytab (id number, data varchar2(40));
mycsv.csv
"ab", "first row"
"cd", "secondrow"
Create control file myctl.ctl:
LOAD DATA
INFILE 'mycsv.csv'
INSERT INTO TABLE mytab
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS (id, data)
Run:
sqlldr cj/cj#localhost/orcl control=myctl.ctl
consider this fiddle link FIDDLE. In this example I would like to use a csv file to load data at line no.33-[data.csv] and data at line no.158-[data1.csv]. I want to use two separate csv files. I tried using a csv file for data at line no.33 with this code
d3.csv("data.csv", function(csvData) {
csvData.forEach(function (d,i) {
data[i] = {
first: +d.first,
second: +d.second
}
});
console.log(data);
I was able to get an output but the charts had moved far away from each other with the following errors : Unexpected value NaN parsing cy attribute. How to load the two datasets in an efficient way using two separate csv files ?
Here is hopefully the final plunker in this ever-growing project :) (A lot of the csv work here has been guided by the great Lars...as usual, many kudos to him.)
Updated plunker with data on top chart coming from datam.csv.