Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Txt to CVS conversion

Hi,

I would like to find a way to convert mathematical constants in txt format to csv format where each digit is it's own entry in the csv file.

Here is my coding so far, but I can't seem to get to work like I want to.

import csv

with open('constants/PiDec.txt','r') as rf:

with open('constants/PiDec.csv','a') as wf:

    csv_writer = csv.writer(wf)

    s_t_r = 1
    i = 1

    f_contents = rf.read(s_t_r)

    while len(f_contents) > 0:

        csv_writer.writerow(f_contents)
        f_contents = rf.read(s_t_r)
        rf.seek(i)
        i = i+1
        f_contents = rf.read(s_t_r)

Txt to CVS conversion

Hi,

I would like to find a way to convert mathematical constants in txt format to csv format where each digit is it's own entry in the csv file.

Here is my coding so far, but I can't seem to get to work like I want to.

import csv

with open('constants/PiDec.txt','r') as rf:

with open('constants/PiDec.csv','a') as wf:

    csv_writer = csv.writer(wf)

    s_t_r = 1
    i = 1

    f_contents = rf.read(s_t_r)

    while len(f_contents) > 0:

        csv_writer.writerow(f_contents)
        f_contents = rf.read(s_t_r)
        rf.seek(i)
        i = i+1
        f_contents = rf.read(s_t_r)

Txt to CVS CSV conversion

Hi,

I would like to find a way to convert mathematical constants in txt format format to csv format where each digit is it's its own entry in the csv file.

Here is my coding code so far, but which does not do what I can't seem to get to work like I want to.want.

import csv

csv with open('constants/PiDec.txt','r') as rf:

rf:

    with open('constants/PiDec.csv','a') as wf:

     csv_writer = csv.writer(wf)

     s_t_r = 1
     i = 1

     f_contents = rf.read(s_t_r)

     while len(f_contents) > 0:

         csv_writer.writerow(f_contents)
         f_contents = rf.read(s_t_r)
         rf.seek(i)
         i = i+1
         f_contents = rf.read(s_t_r)