Dear All, 

There is a workaround to input the file data, it is by opening\selecting  
and reading the file and looping over it as 

file = input ('Enter file name:')
linelist = [line.rstrip('\n') for line in open(file)]
    
print(linelist)
total = 0
count = 0
for line in linelist:
    number = int(line)
    print(number)
    total += number
    count += 1

So far, so good, thus, my question is it is possible to redirect a file of 
data as input in a similar way as Windows Console does?

Thanks,

Sincerely,

Milton


On Wednesday, October 30, 2019 at 6:33:40 PM UTC+1, Milton Eduardo Peña Aza 
wrote:
>
> Dear All, 
> Good day! My name is Milton an would like to kindly ask the following 
> questions:
>
> 1) Would like to input a file of data as input to a test python script 
> wrote in Spyder. However, I do not know how to do it inside Spyder. 
>
> Have managed to do it when running the script in Windows Console (MS-DOS 
> Prompt) by using the command line:
>
>
> C:\Users\milton> python C:\Users\milton\Desktop\uno.py < C:\Users\milton\
> Desktop\integers.dat
>
>
> 2) For the same test script, users have the possibility to interactively 
> insert data and, then, terminate the manual input by typing the EOF 
> Character (Ctrl+Z - Windows), 
>
> Again, this can be achieved in Windows Console
>
> C:\Users\milton> python C:\Users\milton\Desktop\uno.py
> Type integers, each followed by Enter; or CTRL + D or CTRL + Z to finish
> 1
> 2
> 3
> ^Z
> count= 3 total= 6 mean= 2.0
>
>
> Would be very grateful if the group could please provide with some 
> insights on how to do it
>
> Sincerely,
> Milton
>

-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/spyderlib/a4886f33-91b4-42fc-b491-aeb47a4a418f%40googlegroups.com.

Reply via email to