Tuesday, 10 July 2018
RCSV EDITOR
----------------------------------------------------------------------------------------------------------------
READ MORE:
-----------------------------------------------------------------------------------------------------------------
https://sourceforge.net/projects/recsveditor/
https://github.com/limonte/csv-viewer-online
-----------------------------------------------------------------------------------------------------------------
CODE FOR IMPORT AND READ CSV FILE
-----------------------------------------------------------------------------------------------------------------
<head>
<!--
https://limonte.github.io/csv-viewer-online/ -->
<title>CSV VIEWER ONLINE</title>
<link rel="stylesheet" href="https://limonte.github.io/csv-viewer-online/styles.css">
</head>
<body>
<p align="center">
<input type="file" id="input-file" accept=".csv">
</p>
<div id="handsontable-container"></div>
<script src="https://cdn.jsdelivr.net/handsontable/0.28.4/handsontable.full.min.js"></script>
<script src="https://cdn.jsdelivr.net/papaparse/4.1.2/papaparse.min.js"></script>
<script src="https://limonte.github.io/csv-viewer-online/app.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/handsontable/0.28.4/handsontable.full.min.css">
</body>
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CODE FOR EXPORT HTML CODE IN CSV FILE
-----------------------------------------------------------------------------------------------------------------
<html>
<!--
https://halistechnology.com/2015/05/28/use-javascript-to-export-your-data-as-csv/
--><head></head>
<body>
<a href='#' onclick='downloadCSV({ filename: "stock-data.csv"
});'>Download CSV</a>
<script type="text/javascript">
var stockData = [
{
Symbol: "APPLE",
Company: "Apple Inc.",
Price: "132.54"
},
{
Symbol: "INTEL",
Company: "Intel
Corporation",
Price: "33.45"
},
{
Symbol: "GOOGLE",
Company: "Google Inc",
Price: "554.52"
},
];
function convertArrayOfObjectsToCSV(args) {
var result, ctr, keys, columnDelimiter, lineDelimiter,
data;
data = args.data || null;
if (data ==
null || !data.length) {
return null;
}
columnDelimiter = args.columnDelimiter ||
',';
lineDelimiter = args.lineDelimiter ||
'\n';
keys = Object.keys(data[0]);
result = '';
result += keys.join(columnDelimiter);
result += lineDelimiter;
data.forEach(function(item) {
ctr = 0;
keys.forEach(function(key) {
if (ctr >
0) result += columnDelimiter;
result += item[key];
ctr++;
});
result += lineDelimiter;
});
return result;
}
function downloadCSV(args) {
var data, filename, link;
var csv = convertArrayOfObjectsToCSV({
data: stockData
});
if (csv ==
null) return;
filename = args.filename || 'export.csv';
if (!csv.match(/^data:text\/csv/i)) {
csv = 'data:text/csv;charset=utf-8,' + csv;
}
data = encodeURI(csv);
link = document.createElement('a');
link.setAttribute('href', data);
link.setAttribute('download', filename);
link.click();
}
</script>
</body>
</html>
-----------------------------------------------------------------------------------------------------------------?
+
X
Recommended for you
Loading..
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment