Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40211
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; '-----------': 0.04; 'elif': 0.04; 'python)': 0.05; '------------': 0.07; 'data:': 0.07; 'executable': 0.07; 'subject:file': 0.07; 'excluding': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:create': 0.09; 'files.': 0.13; 'resulting': 0.13; '(the': 0.15; '#no': 0.16; 'csv': 0.16; 'duplicates': 0.16; 'feasible': 0.16; 'in-memory': 0.16; 'increment': 0.16; 'one)': 0.16; 'operation.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'row': 0.16; 'appears': 0.18; 'feb': 0.19; 'module': 0.19; 'skip:= 10': 0.20; 'file.': 0.20; 'sort': 0.21; 'file:': 0.22; 'keys': 0.22; 'second': 0.24; 'values': 0.26; 'plain': 0.27; 'header:X -Complaints-To:1': 0.28; 'lines': 0.28; 'rest': 0.28; '(unless': 0.29; 'invoke': 0.29; 'probably': 0.29; 'skip:- 30': 0.31; 'file': 0.32; 'url:home': 0.33; 'anyone': 0.33; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'skip:d 20': 0.34; 'text': 0.34; 'third': 0.34; 'thanks': 0.34; 'skip:k 20': 0.35; 'received:org': 0.36; 'charset :us-ascii': 0.36; 'being': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'help': 0.40; 'your': 0.60; 'first': 0.61; 'more': 0.63; '2013': 0.84; 'dennis': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
| Subject | Re: Read csv file and create a new file |
| Date | Thu, 28 Feb 2013 21:04:32 -0500 |
| Organization | > Bestiaria Support Staff < |
| References | <512fac9c$0$40355$4fafbaef@reader1.news.tin.it> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | adsl-76-253-101-185.dsl.klmzmi.sbcglobal.net |
| X-Newsreader | Forte Agent 3.3/32.846 |
| X-No-Archive | YES |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2697.1362103483.2939.python-list@python.org> (permalink) |
| Lines | 72 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1362103483 news.xs4all.nl 6873 [2001:888:2000:d::a6]:58774 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:40211 |
Show key headers only | View raw
On 28 Feb 2013 19:14:36 GMT, io <maroso@libero.it> declaimed the
following in gmane.comp.python.general:
> Hi,
>
> i have to files.
>
> First file is a csv file
> Second file is a plain text file where each row has a value (text)
>
> I want to be able to create a third file using data from the first file
> excluding the values listed in the second file.
>
> Example:
>
> First file:
> -----------
>
> mtgoxeur 12 24 36
> mtgoxusd 10 12 14
> mtgoxpln 2 4 6
>
>
> Second file:
> ------------
>
> mtgoxusd
>
>
>
> Third File (the resulting one) :
> --------------------------------
>
> mtgoxeur 12 24 36
> mtgoxpln 2 4 6
>
>
>
> Thanks to anyone that can help
>
This appears to be a variation of standard sort/merge operation. The
variation being that you /do not/ write lines of one file when they
match the other file.
While an in-memory sort may be feasible (unless the data file is
extremely large) I would probably invoke your OS sort module on each
file...
Then (pseudo-code, not executable python)
data = csvin.next()
key = keyfile.readln().strip()
while data and key:
if data[0] < key:
csvout.write(data)
data = datafile.readln().strip()
elif data[0] = key:
data =csvin.next()
#don't increment key to catch duplicates in data
elif data[0] > key:
key = keyfile.readln().strip()
while data:
#no more keys to remove, copy rest of data file
csvout.write(data)
data = csvin.next()
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 19:14 +0000
Re: Read csv file and create a new file Neil Cerutti <neilc@norwich.edu> - 2013-02-28 19:32 +0000
Re: Read csv file and create a new file Joel Goldstick <joel.goldstick@gmail.com> - 2013-02-28 14:34 -0500
Re: Read csv file and create a new file Dave Angel <davea@davea.name> - 2013-02-28 14:35 -0500
Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 19:51 +0000
Re: Read csv file and create a new file Neil Cerutti <neilc@norwich.edu> - 2013-02-28 20:11 +0000
Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 20:23 +0000
Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 20:46 +0000
Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 20:51 +0000
Re: Read csv file and create a new file Dave Angel <davea@davea.name> - 2013-02-28 16:23 -0500
Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 22:05 +0000
Re: Read csv file and create a new file Dave Angel <davea@davea.name> - 2013-02-28 19:13 -0500
Re: Read csv file and create a new file Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-28 21:04 -0500
Re: Read csv file and create a new file io <maroso@libero.it> - 2013-03-04 19:04 +0000
Re: Read csv file and create a new file Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-04 23:58 +0000
csiph-web