简体   繁体   中英

Converting all rows from a CSV file to columns

I was able to format my data the way I wanted. After that and with the partial code below, I filled up a matrix with "0"s or "1"s based on output wanted. The problem I have now is with the print statement. Instead of getting a simple output "0011000..." I am getting {(0, 13): 0 , (1, 13): 0 , (2, 13): 1 , (3, 13): 1 , (4, 13): 0 , (5, 13): 0 , (6, 13): 0 ............. How do I get rid of the "extra" symbols "(,{,(,)" and the rows an col positions? Thanks so much

pixels = {}
if on_off == "1":
   pixels  [row, col] = 1                                      
else:
   pixels[row, col] = 0
print(pixels)
for x in range(0, h):
    for y in range(0,w):
         vertical_line = vertical_line +  str( pixels[x][y])
print(vertical_line)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM