Skip to content

bug in DataFrame/DataMatrix toCSV method when index=False #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
changhiskhan opened this issue Jul 27, 2011 · 2 comments
Closed

bug in DataFrame/DataMatrix toCSV method when index=False #81

changhiskhan opened this issue Jul 27, 2011 · 2 comments
Labels

Comments

@changhiskhan
Copy link
Contributor

When index=False an extra column is added because the leading comma is never removed.

def toCSV(self, path, nanRep='', cols=None, header=True, index=True, mode='wb'):

    *<snip>*

    for idx in self.index:

        if index:
            f.write(str(idx))
        for col in cols:
            *<snip>*
            f.write(',%s' % val)
@wesm
Copy link
Member

wesm commented Jul 29, 2011

what version of the code are you looking at? i think this got fixed on 3/15 which was post 0.3.0 release

    for idx in self.index:
        if index:
            f.write(str(idx))
        for i, col in enumerate(cols):
            val = series[col].get(idx)
            if isnull(val):
                val = nanRep
            else:
                val = str(val)

            if i > 0 or index:
                f.write(',%s' % val)
            else:
                f.write('%s' % val)

        f.write('\n')

@wesm
Copy link
Member

wesm commented Jul 31, 2011

gonna go ahead and close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants