Tag: csv

PHP导出到CSV文件在Excel 2007和2010中有不同的行为

我试图使用PHP的fputcsv函数将数组导出到CSV文件。 不过,在Excel 2007和2010中打开文件时,我会遇到两种完全不同的行为。 在Excel 2007中,我得到了我想要的,因为所有的字段都在它自己的独立列中,如下所示: aaa | bbb | ccc | DDDD 123 | 456 | 789 “aaa”| “bbb”| 但在Excel 2010中,所有的字段都是这样的: AAA,BBB,CCC,DDDD 123,456,789 “AAA”, “”, “BBB” “” 如何获得Excel 2007和2010的Excel 2007行为? 我用了下面的脚本: $filename = "test.csv"; //header("Content-Type: application/vnd.ms-excel;"); header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="' . $filename . '"'); header("Pragma: no-cache"); header("Expires: 0"); $list = array ( array('aaa', 'bbb', […]

从一个csv文件获取数据到一个字典

我想从这个文件(indexes.csv)获取信息: 进入这个类的一个实例: class Table { Dictionary<String, double> _regionTimeValues; String _region; public Table(String region) { _regionTimeValues = new Dictionary<string, double>(); _region = region; suckInValues(); } private void suckInValues() { //Go find File, get the appropriate Values for _region //add each value found in the csv file that applies, indexed by yearQuarter //Example: _regionTimeValues.Add("2013Q1", 1.1 ); } […]

用jQuery导出html-table

我想用javascript导出html表格的内容。 首先,我将遍历所有的TD元素,并收集数据,将其发送到另一个PHP页面,从而生成CSV-Excel。 或者我可以使用另一个框架,已经包含这个function?

Excel中由Python写出的CSV是完全空白的

我有一个简单的字典,我正在写一个CSV文件,它看起来很好,当我在服务器上查看它,但它是完全空白的Excel。 csvOutput = {'http://www.test.com/': 'This source is currently in the system.', 'http://test.com/': 'This source is not currently in the system.', 'http://www.test.com/': 'This source is currently in the system.'} writer = csv.writer(open(csvFileName, 'wb'), quoting=csv.QUOTE_NONE, dialect='excel') for key, value in csvOutput.items(): writer.writerow([key, value]) 谢谢你的帮助! 这里是我在vim中看到的文件: http://www.test.com/,This source is currently in the system. http://test.com/,This source is not currently […]

python csv将string写入1个单元格

我使用facebook api来获取时间,将其转换为不同的格式,然后将其写入一个csv文件。 除了当string被写入时,一切运作良好,它将string分隔成2个不同的单元格,如下所示: 帮我把它全部放进1格。 谢谢。 我的代码: import csv from datetime import * from time import * from facepy import * token = 'CAAErZAZAHDByABA…………' graph = GraphAPI(token) g = graph.get('apple/posts?limit=4') mytime = g['data'][0]['created_time'] ctime = datetime(*strptime(mytime, "%Y-%m-%dT%H:%M:%S+0000")[0:6]).strftime("%B %d, %Y %I:%M %p") with open('csvtest.csv', 'a') as csvfile: spamwriter = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL) spamwriter.writerow([ctime])

关于转换.CSV文件的date

我正在使用软件。 从那里我得到了.CSV格式的文件。 现在我需要将该.CSV文件转换为Excel 2007,然后我必须使用该文件。 在那里我有上个月的date和当前的月份date。 例如,我在五月工作意味着date是13/05/2013这是标准格式,但在一些单元格中,我发现格式更改为3/5/2013(05年3月5日)但它应该是5 / 3/2013 如何改变这个 – 任何公式或格式?

VBScript用户inputvariables

我正在创build一个脚本来分割csv文件,我想让用户input文件被分割成新的时间间隔。 我遇到的问题是,当我input的时间间隔不是分裂的,但是如果我硬编码的价值在它分裂。 Option Explicit Const ForReading = 1 Const ForWriting = 2 Dim objFSO, objInputFile, objOutputFile Dim intLine, intFile Dim strHeaders Dim strInputFile, strOutputPrefix, strLine Dim MyDate Dim userSplit Dim split 'strInputFile = InputBox("Enter file location") strInputFile = "H:\VBS\domS_CUST.csv" strOutputPrefix = strInputFile & DatePart("yyyy", Now) & "-" & DatePart("m", Now) & "-" & DatePart("d", Now) […]

VBScript打开文件夹将csv转换为xls

任何人都可以解释为什么这不起作用,它抛出一个错误说: 行:14字符:1错误:对象需要:'[string:“H:\ VBS”]'代码:800A01A8 Const xlDelimited = 1 Const xlNormal = -4143 Set Excel = CreateObject("Excel.Application") Set fso = CreateObject("Scripting.FileSystemObject") Dim Excel dim objShell dim objFolder Dim fileLocation set objShell = CreateObject("shell.application") set objFolder = objshell.BrowseForFolder(0, "Select File Location", 1, "H:\") set fileLocation = CStr(objFolder.self.path) Set Excel = CreateObject("Excel.Application") Set fso = CreateObject("Scripting.FileSystemObject") folderDestination = InputBox("Enter […]

使用Python启动Excel应用程序来查看CSV文件,但是CSV文件在读取模式下打开,并且无法查看写入的数据

from win32com.client import Dispatch base_path = os.path.dirname(os.path.abspath(__file__)) _csvFilename = os.path.join(base_path, "bcForecasting.csv") _csvFile = open (_csvFilename, 'wb') _csvFile = csv.writer(_csvFile, quoting=csv.QUOTE_ALL) _Header = ['Name']+self.makeIntoList (self.root.tss.series () [0].getAllTimes (), self.originalTimesteps + _futurePeriods) _csvFile.writerow (_Header) xl = Dispatch('Excel.Application') wb = xl.Workbooks.Open(_csvFilename) xl.Visible = True 这里使用Python启动Excel应用程序来查看CSV文件,但是CSV文件在读取模式下打开,无法查看写入的数据。 请帮忙。

试图出口微软excel中的csv像中文这样的特殊字符,但失败了

我有一个Web应用程序,我试图从数据库导出到CSV。 它与英文字符集完美运行,但是当我把一些中文文本在数据库中我的CSV显示哑巴字符像???? 。 <?php $con=mysqli_connect(global_dbhost,global_dbusername,global_dbpassword,global_dbdatabase); if(isset($_GET['csv'])) { $query ='SELECT CONCAT("TC00", `t_id`),m_id,s_id,t_name,Description,start_date,end_date,start_time,end_time,status,active FROM tc_task'; $today = date("dmY"); //CSVExport($query); $con=mysqli_connect(global_dbhost,global_dbusername,global_dbpassword,global_dbdatabase); //echo 'inside function'; $sql_csv = mysqli_query($con,$query) or die("Error: " . mysqli_error()); //Replace this line with what is appropriate for your DB abstraction layer file_put_contents("csvLOG.txt","\n inside ajax",FILE_APPEND); header("Content-type:text/octect-stream"); header("Content-Disposition:attachment;filename=caring_data".$today.".csv"); while($row = mysqli_fetch_row($sql_csv)) { print '"' . stripslashes(implode('","',$row)) . […]