librelist archives

« back to archive

Re: Parsing a big file

Re: Parsing a big file

From:
Daniel Gonzalez
Date:
2012-04-10 @ 09:52
Hello,

This is what I usually do to parse a file with pystache:

txt = open(filename, 'r').read()
print pystache.render(txt, context).encode('utf-8')

("context" is my mapping)

But now I have to parse very big files. Is there a suggested way to do
this, without reading the whole file into memory?
Does pystache have internal support for this?

Thanks,
Daniel Gonzalez

Re: [pystache] Re: Parsing a big file

From:
Chris Jerdonek
Date:
2012-04-10 @ 14:42
No, pystache currently doesn't support that (operating on file
streams).  I would recommend adding an issue for that on the GitHub
site.

Thanks,
--Chris


On Tue, Apr 10, 2012 at 2:52 AM, Daniel Gonzalez <gonvaled@gonvaled.com> wrote:
> Hello,
>
> This is what I usually do to parse a file with pystache:
>
> txt = open(filename, 'r').read()
> print pystache.render(txt, context).encode('utf-8')
>
> ("context" is my mapping)
>
> But now I have to parse very big files. Is there a suggested way to do
> this, without reading the whole file into memory?
> Does pystache have internal support for this?
>
> Thanks,
> Daniel Gonzalez

Re: [pystache] Re: Parsing a big file

From:
Daniel Gonzalez
Date:
2012-04-20 @ 22:28
Thanks, I have added it as an issue in GitHub.

On Tue, Apr 10, 2012 at 4:42 PM, Chris Jerdonek <chris.jerdonek@gmail.com>wrote:

> No, pystache currently doesn't support that (operating on file
> streams).  I would recommend adding an issue for that on the GitHub
> site.
>
> Thanks,
> --Chris
>
>
> On Tue, Apr 10, 2012 at 2:52 AM, Daniel Gonzalez <gonvaled@gonvaled.com>
> wrote:
> > Hello,
> >
> > This is what I usually do to parse a file with pystache:
> >
> > txt = open(filename, 'r').read()
> > print pystache.render(txt, context).encode('utf-8')
> >
> > ("context" is my mapping)
> >
> > But now I have to parse very big files. Is there a suggested way to do
> > this, without reading the whole file into memory?
> > Does pystache have internal support for this?
> >
> > Thanks,
> > Daniel Gonzalez
>