本文目錄一覽:
csv文件怎麼打開
csv文件怎麼打開
方法一
1、不用任何軟件,使用電腦中的寫字板來打開csv文件。
2、在電腦桌面,點擊左下方的“開始”。
3、點擊所有程序——附件——寫字板。
4、在跳出的’寫字板上,鼠標點擊文件——打開。
5、在文件類型下選擇全部文檔,選取要打開的csv文件,點擊打開。
6、打開後的結果,如下圖顯示。
方法二
1、用office excel 2007軟件也可以打開csv文件。如果電腦上裝了Microsoft Excel的話,.csv文件默認是被Excel打開的。
2、在電腦桌面打開office excel 2007軟件,點擊office按鈕——打開。
3、在文件類型下選擇文本文件,點擊csv文件——打開。
4、隨後,會跳出文件導入嚮導,共有3步。如沒有特殊情況直接點擊下一步i,直至完成。
5、打開後的結果,如下圖顯示。
用js如何實現點擊按鈕打開一個指定路徑下的文件
方法步驟如下:
1、首先,打開計算機,然後打開JS,在其中創建一個HTML文件“test”。
2、然後將HTML框架添加到測試文件中。
3、然後添加兩個輸入,一個是button,另一個是file將ID設置為“open”樣式類型為“display:None”並且不顯示。
4、打開後,僅顯示此“打開文件”按鈕。
5、現在將onclick事件添加到按鈕,並調用openfile來觸發ID為“open”的文件。
6、現在單擊瀏覽器中的“打開文件”就會彈出選擇文件路徑對話框。
javascript 讀取csv文件
js讀取CSV格式數據,參考如下:
script type=”text/javascript”
// This will parse a delimited string into an array of
// arrays. The default delimiter is the comma, but this
// can be overriden in the second argument.
function CSVToArray( strData, strDelimiter ){
// Check to see if the delimiter is defined. If not,
// then default to comma.
strDelimiter = (strDelimiter || “,”);
// Create a regular expression to parse the CSV values.
var objPattern = new RegExp(
(
// Delimiters.
“(\\” + strDelimiter + “|\\r?\\n|\\r|^)” +
// Quoted fields.
“(?:\”([^\”]*(?:\”\”[^\”]*)*)\”|” +
// Standard fields.
“([^\”\\” + strDelimiter + “\\r\\n]*))”
),
“gi”
);
// Create an array to hold our data. Give the array
// a default empty first row.
var arrData = [[]];
// Create an array to hold our individual pattern
// matching groups.
var arrMatches = null;
// Keep looping over the regular expression matches
// until we can no longer find a match.
while (arrMatches = objPattern.exec( strData )){
// Get the delimiter that was found.
var strMatchedDelimiter = arrMatches[ 1 ];
// Check to see if the given delimiter has a length
// (is not the start of string) and if it matches
// field delimiter. If id does not, then we know
// that this delimiter is a row delimiter.
if (
strMatchedDelimiter.length
(strMatchedDelimiter != strDelimiter)
){
// Since we have reached a new row of data,
// add an empty row to our data array.
arrData.push( [] );
}
// Now that we have our delimiter out of the way,
// let’s check to see which kind of value we
// captured (quoted or unquoted).
if (arrMatches[ 2 ]){
// We found a quoted value. When we capture
// this value, unescape any double quotes.
var strMatchedValue = arrMatches[ 2 ].replace(
new RegExp( “\”\””, “g” ),
“\””
);
} else {
// We found a non-quoted value.
var strMatchedValue = arrMatches[ 3 ];
}
// Now that we have our value string, let’s add
// it to the data array.
arrData[ arrData.length – 1 ].push( strMatchedValue );
}
// Return the parsed data.
return( arrData );
}
/script
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/185578.html