export-to-csv

Ruby: How to generate CSV files that has Excel-friendly encoding

让人想犯罪 __ 提交于 2019-11-30 19:35:39
I am generating CSV files that needs to be opened and reviewed in Excel once they have been generated. It seems that Excel requires a different encoding than UTF-8. Here is my config and generation code: csv_config = {col_sep: ";", row_sep: "\n", encoding: Encoding::UTF_8 } csv_string = CSV.generate(csv_config) do |csv| csv << ["Text a", "Text b", "Text æ", "Text ø", "Text å"] end When opening this in Excel, the special characters are not being displayed properly: Text a Text b Text æ Text ø Text Ã¥ Any idea how to ensure proper encoding? The top voted answer from @joaofraga worked for me,

Column ordering when exporting to CSV in PowerShell - controlling the property enumeration order of custom objects created from hashtables

爷,独闯天下 提交于 2019-11-30 18:46:19
I'm writing a script in Powershell that exports all securitygroups and their members from Active Directory . Now I want to format the output of the .csv . The Code: $Groups = Get-ADGroup -Properties * -Filter * -SearchBase "OU=SERVICES,DC=XXXXXX,DC=XXXXX" $Table = @() $Record = @{ "Group Name" = "" "Name" = "" "Username" = "" } Foreach($G In $Groups) { $Arrayofmembers = Get-ADGroupMember -identity $G -recursive | select name,samaccountname Foreach ($Member in $Arrayofmembers) { $Record."Group Name" = $G.Name $Record."Name" = $Member.name $Record."UserName" = $Member.samaccountname $objRecord =

How to convert .Rdata format into text file format

谁都会走 提交于 2019-11-30 17:39:58
I am a novice in R and I am trying to convert .Rdata format file into comma delimited text file format. Can someone help me out regarding this? load("yourData.RData") ls() #returns a list of all the objects you just loaded (and anything else in your environment) write.csv(theItemOfInterestFromYourDRadataFileAsThereMayBeMoreThanOneThingInthere, file="yourCSV.csv") An .RData file can contain more than 1 object of any class. If your file contains more than 1 object of data.frame -like class, then the following should work resave <- function(file){ e <- new.env(parent = emptyenv()) load(file,

How to export an entity as a CSV in Symfony?

放肆的年华 提交于 2019-11-30 16:13:45
I am using the following code to output a CSV but I am getting a blank screen when I run it. basically my confusion is with the DoctrineORMQuerySourceIterator as I am not understanding how to use that properly. I am assuming I have to list out the property names ???? I am using the Sonata Exporter: https://github.com/sonata-project/exporter <?php $repository = $this->getDoctrine()->getRepository('MainReferralCaptureBundle:Referral'); $referrals = $repository->createQueryBuilder('r')->select('r.pLastName, r.pFirstName')->getQuery(); // $referrals2 = $referrals->getResult(); // var_dump(

QTableView export to .csv number of rows fetched is limited to only 256

落爺英雄遲暮 提交于 2019-11-30 16:08:16
I wrote a gui program which will connect to an oracle db an retrieve data after a query is typed. the retrieved data is shown in a QTableView table model widget. and later the result of the QTableView is exported to a .csv file QString MyQuery = ui->lineQuery->text(); db.open(); QSqlQuery query(MyQuery,db); if(query.exec()) { qDebug()<<QDateTime::currentDateTime()<<"QUERY SUCCESS "; ui->queryButton->setStyleSheet("QPushButton {background-color: rgb(0, 255, 0);}"); this->model=new QSqlQueryModel(); model->setQuery(MyQuery); ui->tableViewOra->setModel(model); QString textData; int rows=model-

MySQL export to CSV file as UTF-8 via Python script

99封情书 提交于 2019-11-30 16:07:35
I'm able to export a MySQL table into a CSV file via Python csv module but there are no utf-8 characters. (example: ???? chars insted of ąöę ). The table data is in utf-8 format (phpMyAdmin let me see correct data). I found some information that in Python all data should be decoded in utf-8 and then encoded into CSV in utf-8 via for example unicodewritter (because the native csv module doesn't support Unicode correctly). I tried a lot but no success. Question : Is there any example script to export MySQL database in utf-8 to CSV file in utf-8 format in Python? I use ubuntu 14.04 and there is a

Live Plot in Python GUI

二次信任 提交于 2019-11-30 15:42:15
I am trying to write a Python GUI and I need to do a live plot. I currently have a program that receives data from a machine I am using and I want to be able to plot the values the machine outputs as I receive them. I have been researching and from what I have found so far, it doesn't seem to me like tkinter or any library can do this in a GUI. Does anyone know whether and how tkinter can do this or if there is another library that is capable of doing such a live plot? Also, how would I go about writing the data that I gather to a file as I receive the data? Thanks in advance for your help. It

How to make fputcsv “echo” the data

百般思念 提交于 2019-11-30 10:51:54
I need a way to make the fputscv function write data to the browser on-the-fly instead of creating a temporary file, saving data into that file and doing a echo file_get_contents() . Found this on the PHP docs website, first comment under the function reference: function outputCSV($data) { $outstream = fopen("php://output", 'w'); function __outputCSV(&$vals, $key, $filehandler) { fputcsv($filehandler, $vals, ';', '"'); } array_walk($data, '__outputCSV', $outstream); fclose($outstream); } And a second option: $csv = fopen('php://temp/maxmemory:'. (5*1024*1024), 'r+'); fputcsv($csv, array('blah'

Use psql's \\copy for a multi-line query

不打扰是莪最后的温柔 提交于 2019-11-30 07:59:24
This is a follow-up question from this answer for " Save PL/pgSQL output from PostgreSQL to a CSV file ". I need to write a client-side CSV file using psql's \copy command . A one liner works: db=> \copy (select 1 AS foo) to 'bar.csv' csv header COPY 1 However, I have long queries that span several lines. I don't need to show the query, as I can't seem to extend this past one line without a parse error: db=> \copy ( \copy: parse error at end of line db=> \copy ( \\ \copy: parse error at end of line db=> \copy (" \copy: parse error at end of line db=> \copy "( \copy: parse error at end of line

Export sheet as UTF-8 CSV file (using Excel-VBA)

被刻印的时光 ゝ 提交于 2019-11-30 07:39:25
问题 I would like to export a file I have created in UTF-8 CSV using VBA. From searching message boards, I have found the following code that converts a file to UTF-8 (from this thread): Sub SaveAsUTF8() Dim fsT, tFileToOpen, tFileToSave As String tFileToOpen = InputBox("Enter the name and location of the file to convert" & vbCrLf & "With full path and filename ie. C:\MyFolder\ConvertMe.Txt") tFileToSave = InputBox("Enter the name and location of the file to save" & vbCrLf & "With full path and