I put the code on a pastebin thingy so this post would be easier to read.
http://paste.pocoo.org/show/229111/

Anyways, basically, I have this 250MB text file that has a string of letters. 50 letters per line, and LOTS and LOTS of lines. I tried doing this before, but I got a Memory Error because I tried to read the whole file at once and put it on one line. Not good.

So, I was told to use Generators. This is what I got. It "works," but it'll run through in a split second, and the file it writes to will have an empty dictionary in it.

Help? Thanks in advance.

Recommended Answers

All 5 Replies

Could you include small part of each file processed or real log. Did you try putting test prints in various places in code to see what is being processed and if the intended control flow is accomplished and intended input is read? Include indication of place in code, not only variable print.

Maybe you should also put some assert statements in code to see the logic of your coding is right.

A small part of the file processed? Like what I'm reading from and writing to? Everything's blank except the chr1.fa. And chr1.fa's basically stuff like:
">chr1.fa
ATGACGTGCCGTCGAGCG
GTcggtcggaagtcgtc"
and etc. except there are 50 letters per line (except the first one that has the file name in it), and the file changes from upper to lower case and vice versa occasionally.

And, well, except for the part I notated that I was working/worked on, I did test prints. Tomorrow, I'll try out the code and see where it's going wrong. I just find debugging to be such a pain in the butt.

And what are assert statements. ?_?

Moo, how did you get to that? Its very different then it was before.
This is a better way to check if a user have entered a "yes"

if (import_yn in "y yes yeah".split()):
    #code

Oh, hey redyugi, lol. I had help from people in #python in an irc. And I'm not really planning on making this for distribution or anything fancy but for the use of my internship so that's not my biggest concern P:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.