export-to-csv

S3 Select retrieve headers in the CSV

偶尔善良 提交于 2019-12-11 01:34:12
问题 I am trying to fetch a subset of records from a CSV stored in an S# bucket using the following code: s3 = boto3.client('s3') bucket = bucket file_name = file sql_stmt = """SELECT S.* FROM s3object S LIMIT 10""" req = s3.select_object_content( Bucket=bucket, Key=file, ExpressionType='SQL', Expression=sql_stmt, InputSerialization = {'CSV': {'FileHeaderInfo': 'USE'}}, OutputSerialization = {'CSV': {}}, ) records = [] for event in req['Payload']: if 'Records' in event: records.append(event[

Ensuring long digits are maintained in CSV output

若如初见. 提交于 2019-12-10 18:03:40
问题 I have an R data frame which needs to be saved as a csv file however one numeric column changes its format when saved as a csv file. I have a character column named ID as below: df <- data.frame(ID = as.character(1181050000000002, 1189050000000003), Other = c("John", "Mary")) When I save as a csv file on r, it changes to write.csv(df, "df.csv", row.names = FALSE) df <- read.csv("df.csv") df$ID ID 1181050000000000 1189050000000000 The output when I open the csv file should appear as original

Quote only the required columns using pandas to_csv

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 17:52:10
问题 I need to generate a csv using pandas to_csv function. I tried quote=csv.QUOTE_NONNUMERIC. But for one of the date time column I dont need double quotes. Is there a way to select the columns for which we want double quotes? 回答1: Thanks people. I got the answer so just thought to share. First I got the list of headers to be quoted and looped them something like below: for col in quoteColumnsList: df[col] = '"' + df[col] + '"' Here my quotechar is '"'. Now I used to_csv with quote parameter as

Yet struggling to parse JSON with jq

自作多情 提交于 2019-12-10 15:28:44
问题 I'm slowly getting a grip of how jq works but am still far from mastering it. Now I'm in a situation I've kinda managed to get what I wanted but not to display it the way I want. I'm sure it's quite simple but I'm missing it... Here's a sample of the JSON I want to parse: { "sites": [ { "site_id": 123456, "status": "configured", "domain": "www.domain.com", "account_id": 654321, "security": { "waf": { "rules": [ { "action": "block_request", "action_text": "Block", "id": "sqli", "name": "SQLi"

writing colored output into CSV file in Python

橙三吉。 提交于 2019-12-10 10:58:46
问题 I have a program to write content into a CSV file using CSV module in Python. My requirement is to show text in color if a given condition is satisfied. Does anyone has pointers on how to achieve this using CSV module? Appreciate your help. Thanks! MSH. 回答1: You should use an excel file for this, because csv files are merely plain text files that cannot keep any coloring formatting within them. Basically, the only time a CSV file may seem like it's got formatting is when it's opened in Excel.

Python write 2 lists and Pandas DataFrames to csv/excel sequentially

∥☆過路亽.° 提交于 2019-12-10 10:47:31
问题 I have these Python lists and Pandas Dataframes: list_1 = ['Intro line here - record of method function:'] list_2 = ['Record of local minimum follows:'] print df_1 Col_A Col_B 3.4443 1.443 10.8876 11.99 print df2 Trial_1 Trial_2 Trial_3 1.1 1.49 775.9 11.5 9.57 87.3 384.61 77.964 63.7 12.49 0.156 1.9 112.11 11.847 178.3 Here is what I want in the output csv or excel file - either csv or excel would work for me: Intro line here - record of method function: Col_A Col_B 3.4443 1.443 10.8876 11

Saving output of confusionMatrix as a .csv table

谁说我不能喝 提交于 2019-12-10 10:22:02
问题 I have a following code resulting in a table-like output lvs <- c("normal", "abnormal") truth <- factor(rep(lvs, times = c(86, 258)), levels = rev(lvs)) pred <- factor( c( rep(lvs, times = c(54, 32)), rep(lvs, times = c(27, 231))), levels = rev(lvs)) xtab <- table(pred, truth) library(caret) confusionMatrix(xtab) confusionMatrix(pred, truth) confusionMatrix(xtab, prevalence = 0.25) I would like to export the below part of the output as a .csv table Accuracy : 0.8285 95% CI : (0.7844, 0.8668)

Why write.csv and read.csv are not consistent? [closed]

陌路散爱 提交于 2019-12-10 02:25:13
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . The problem is simple, consider the following example: m <- head(iris) write.csv(m, file = 'm.csv') m1 <- read.csv('m.csv') The result

How to format output when exporting SQL query to CSV

旧街凉风 提交于 2019-12-09 23:16:11
问题 I have a task to save the results of a SQL Server query into a .csv file. After some googling I decided to use PowerShell. I found a script, modified it a bit, it works and almost all is ok. $server = "server" $database = "database" $query = "SELECT * from et_thanks" $tod = Get-Date; $file = "{0:yyyyMMdd}_go.csv" -f $tod; $extractFile = @" \\info\export_files\$file "@ $connectionTemplate = "Data Source={0};Integrated Security=SSPI;Initial Catalog={1};" $connectionString = [string]::Format(

ANGULAR 5 : how to export data to csv file

只谈情不闲聊 提交于 2019-12-09 05:38:07
问题 I am beginner in angular and I am working on Angular 5, Node v8.11.3. I want to realize a generic function that takes in parameter data and headers. And as output a csv file. I create a component called ' FactureComponent ' Then I generate a service called ' DataService ' then I create a getFactures function that retrieves a list of my items from a mock and it works very well. import { Component, OnInit } from '@angular/core'; import { DataService } from '../data.service'; import { FACTURES }