So I got .txt file with around 200 lines, each contains a (x,y) location ranging from 0 to 255. I want to draw dot, or "," at each location.. so (0,5) will draw 5 spaces in first line and then the ",".
Using python, is there a way to print it to the terminal that way? if not, is there a way to create .txt file with the "image" or any other way to view the resulting "image" (its just bunch of ","'s) thanks.
EDIT:
The .txt file is something I extracted from challenge. The challenege was to decode the output of given binary file. This is the original file: https://elbitcareer.hunterhrms.com/wp-content/uploads/elbitsystems.elbit
This is the .txt coords I managed to extract from the file: https://easyupload.io/imtbdn
And this is what it looks like when I print it to the terminal:
It looks like the right direction (SYSCO..?) but something is off.. Any ideas on what is the problem?
EDIT2: So my .txt file was missing some points and my terminal window needed some resizing.. now it kinda workds! thanks all.
I wrote some code and the output seems to be just like yours but a little more. So the problem must be in the console size. I used out.txt file and this code:
import numpy as np
xmax = 0
ymax = 0
with open('out.txt', 'r') as f:
while f.readline() !='':
line = f.readline()
if line and "," in line:
x, y = line.split(',')
x = int(x)
y = int(y)
if x > xmax:
xmax = x
if y > ymax:
ymax = y
f.close()
pic = np.zeros((xmax+1,ymax+1))
with open('out.txt', 'r') as f:
while f.readline() !='':
line = f.readline()
if line and "," in line:
x, y = line.split(',')
x = int(x)
y = int(y)
pic[x][y] = 1
print(xmax,ymax)
with open('picture.txt', 'w') as f:
for y in range(ymax):
for x in range(xmax):
if pic[x][y] == 1:
f.write('.')
else:
f.write(' ')
f.write('\n')
This code works in 4 steps:
The output file is picture.txt and looks like this:
try to change size of your terminal console and will be good :)