Generate Date CSV
How do I make an generate date csv?
What is a generate date csv? How do you make a generate date csv? This script and codes were developed by Adnene Manai on 15 October 2022, Saturday.
Generate Date CSV - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Generate Date CSV</title>
</head>
<body> <pre id="csv">
</pre> <script src="js/index.js"></script>
</body>
</html>
Generate Date CSV - Script Codes JS Codes
var MONTHS = { Jan:'01 Jan', Feb:'02 Feb', Mar:'03 Mar', Apr:'04 Apr', May:'05 May', Jun:'06 Jun', Jul:'07 Jul', Aug:'08 Aug', Sep:'09 Sep', Oct:'10 Oct', Nov:'11 Nov', Dec:'12 Dec'
}
var DAYS = { Mon:'01 Mon', Tue:'02 Tue', Wed:'03 Wed', Thu:'04 Thu', Fri:'05 Fri', Sat:'06 Sat', Sun:'07 Sun'
}
var startDate = new Date('2011','0','01');
var endDate = new Date - 0;
Date.prototype.getWeek = function() { var onejan = new Date(this.getFullYear(), 0, 1); return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7);
}
// JSON to CSV Converter
function ConvertToCSV(objArray) { var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray; var str = ''; for (var i = 0; i < array.length; i++) { var line = ''; for (var index in array[i]) { if (line != '') line += ';' line += array[i][index]; } str += line + '\r\n'; } return str;
}
function getAllDays() { var s = new Date(startDate - 0); var e = new Date(endDate- 0); var a = []; a.push({ id:'id:PK', day_name:'day_name', month_name:'month_name', day_number:'day_number', year:'year', week_number:'week_number', value_1: 'value_1', value_2: 'value_2', value_3: 'value_3', value_4: 'value_4' },{ id:'string', day_name:'string', month_name:'string', day_number:'string', year:'string', week_number:'string', value_1: 'double', value_2: 'double', value_3: 'double', value_4: 'double' } ); while(s < e) { var splitDate = s.toDateString().split(' '); a.push({ id:s.toISOString(), day_name:DAYS[splitDate[0]], month_name:MONTHS[splitDate[1]], day_number:("0" + splitDate[2]).slice(-2), year:splitDate[3], week_number:("0" + s.getWeek()).slice(-2), value_1: Math.floor(Math.random() * 25) + 1, value_2: Math.floor(Math.random() * 50) + 1, value_3: Math.floor(Math.random() * 75) + 1, value_4: Math.floor(Math.random() * 100) + 1 }); s = new Date(s.setDate(s.getDate() + 1)) } return a;
};
console.log(ConvertToCSV(JSON.stringify(getAllDays())));
document.getElementById('csv').innerHTML=ConvertToCSV(JSON.stringify(getAllDays()))
Developer | Adnene Manai |
Username | adnmanai |
Uploaded | October 15, 2022 |
Rating | 3 |
Size | 2,204 Kb |
Views | 18,216 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Gallery | 3,348 Kb |
Quick starter with Angularjs | 1,662 Kb |
Generate Stock Date CSV | 2,359 Kb |
Etienne Cendrier | 4,564 Kb |
Flexbox Gallery with Angularjs | 1,863 Kb |
Svg ani | 14,097 Kb |
Angularjs - 8 cards carrousel | 3,571 Kb |
A Pen by Adnene Manai | 1,641 Kb |
Gallery unsplash | 3,385 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
React Template | Isac | 1,241 Kb |
After America | Jonathangarner | 2,686 Kb |
A Pen by John Malc | F789gh | 1,420 Kb |
To Do List with Delete | Mattlbrody | 2,068 Kb |
Custom Select Element | Agrayson | 3,616 Kb |
Canvas Fireworks | Jackrugile | 6,200 Kb |
Classy Blockquote Styling | Andrewwright | 3,212 Kb |
CSS3 Snow Animation | NickyCDK | 1,695 Kb |
SlideupBoxes | Gavra | 23,772 Kb |
Sass Get Function | Lukewatts | 2,155 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!