Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"A verbal contract isn't worth the paper it's printed on." -- Samuel Goldwyn


devel / comp.lang.python / Re: Flask – how to write csv file & save using prefilled value of the filename (response.headers["Content-Disposition"]="attachment; filename=xxx")

SubjectAuthor
o Re: Flask – how to write csv file & save usinMRAB

1
Re: Flask – how to write csv file & save using prefilled value of the filename (response.headers["Content-Disposition"]="attachment; filename=xxx")

<mailman.322.1628266444.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14483&group=comp.lang.python#14483

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: pyt...@mrabarnett.plus.com (MRAB)
Newsgroups: comp.lang.python
Subject: Re:_Flask_–_how_to_write_csv_file_&_save_usin
g_prefilled_value_of_the_filename_(response.headers["Cont
ent-Disposition"]="attachment; filename=xxx")
Date: Fri, 6 Aug 2021 17:13:54 +0100
Lines: 20
Message-ID: <mailman.322.1628266444.4164.python-list@python.org>
References: <CAOnJk35VxSXA8J-gFxTZndNZZW5AGjjEQ1hTjg4+uZF9fzREbg@mail.gmail.com>
<a3932394-c4e5-a305-6fbe-211b0c977338@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de DqDWwZFSmmdoqSALhpUTHAKL8Gh5qjuRFNKGwWzD4Scg==
Return-Path: <python@mrabarnett.plus.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=plus.com header.i=@plus.com header.b=IQ6jffkl;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:value': 0.07;
'from:addr:python': 0.09; 'received:192.168.1.64': 0.09;
'subject:Flask': 0.09; 'subject:csv': 0.09; 'subject:how': 0.09;
'problem': 0.15; '[snip]': 0.16; 'from:addr:mrabarnett.plus.com':
0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com':
0.16; 'object,': 0.16; 'received:84.93': 0.16;
'received:84.93.230': 0.16; 'received:plus.net': 0.16; 'subject:;
': 0.16; 'subject:filename': 0.16; 'subject:save': 0.16;
'subject:skip:r 10': 0.16; 'upload': 0.16; 'wrote:': 0.16;
'python': 0.16; 'csv': 0.20; 'subject:file': 0.23; 'to:addr
:python-list': 0.23; 'subject:using': 0.24; 'header:User-Agent:1':
0.31; 'received:192.168.1': 0.31; 'but': 0.31; 'expect': 0.31;
'script': 0.32; 'using': 0.33; 'header:In-Reply-To:1': 0.33;
'same': 0.34; 'trying': 0.36; 'able': 0.36; 'received:192.168':
0.37; 'file': 0.38; 'read': 0.38; "skip:' 10": 0.40; 'back': 0.65;
'skip:f 20': 0.76; 'subjectcharset:utf-8': 0.80; 'subject:
\xe2\x80\x93 ': 0.84; 'subject:\xe2\x80\x93': 0.84;
'subject:Content': 0.91; 'produces': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
t=1628266435; bh=a0SKzNLMWncnDyX+umauZ+XCIwfDth16v5uRypuMxZM=;
h=Subject:To:References:From:Date:In-Reply-To;
b=IQ6jffklOdn/6IiUv2G/LWlarDUJaUiXwebxCYL+byr7X+Fjr0g+X135dsyiofeVv
vUISorIex6U9/O+ml3yjUA7/HSs654FdAa9VkVICZ0qHK1n/8vzMRd7spDC66t/RGY
19+U4hJRbcDB7G4s51Py1BJdf6FACo4mH1kT1/T7q/QTIGHkuqEaizbsNK7U52u1In
NMkESLFrlvC3L+zgfCRt2G7VTx3n15C3zH9i/hCCFajUW1G+yVAV8j88xVsx75Fv01
4q0wupz0a42aZ2Dhl/R+9tinKDONpT+jE07Raq+YexbqVHlQb7gDjS8A14nGdaAxk4
vv9tRMwLAG3fQ==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.3 cv=S85CPLkP c=1 sm=1 tr=0
a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
a=IkcTkHD0fZMA:10 a=5KLPUuaC_9wA:10 a=PikPSwZmKFXm4FS42WoA:9 a=QEXdDO2ut3YA:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
In-Reply-To: <CAOnJk35VxSXA8J-gFxTZndNZZW5AGjjEQ1hTjg4+uZF9fzREbg@mail.gmail.com>
Content-Language: en-GB
X-CMAE-Envelope: MS4wfBrLZwNeHqL9AjGv/X8P/bPXcSA+fNXRgFx6faZCh088QL5Zvpmg8w9pYm56whNoWrcEgnoB+BoKVZ7KsaNJzjvimyIa6s21CH5XaGMRtf+UdJUdK0hb
+bnhu3LV9uVcomDcRnof8/jXCWL2yiERkJdxeYFP+fecClpLvAfs7vsD+LJIjjKHZPoT1Q//AX7Lqg==
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <a3932394-c4e5-a305-6fbe-211b0c977338@mrabarnett.plus.com>
X-Mailman-Original-References: <CAOnJk35VxSXA8J-gFxTZndNZZW5AGjjEQ1hTjg4+uZF9fzREbg@mail.gmail.com>
 by: MRAB - Fri, 6 Aug 2021 16:13 UTC

On 2021-08-06 16:50, Suretha Weweje wrote:
> I am trying to upload a CSV file with flask, read and process one line at a
> time while iterating through all rows of the file and write the results
> back to a new CSV file. My python script produces the correct results on
> its own, but I am not able to get the same results when using Flask. I am
> new to flask.
>
[snip]
>
> csv_reader = csv.reader(new)
>
[snip]
>
> *mywriter = csv.DictWriter('results.csv', fieldnames=headers_new)*
[snip]

The problem has nothing to do with Flask.

'csv.reader' and 'csv.DictWriter' expect a file object, but you're
passing them strings.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor