Raghav Gupta
				
				
			 
			
	
	
	
		
	
	
			
		
		
			
			
				- 1,010
 
- 76
 
Homework Statement
Read a comma separated numeric (int, float, comp, bool) values from a file and store each
comma separated value in a list[/B]. Sort the list (without using in-built sort/sorted function)
and write it to output file in comma separated format.
In my attempt I am not able to do the bold part in the question. That is if float value is there in file then it cannot be typecasted to int. How do I typecast with conditions?
Homework Equations
NA
The Attempt at a Solution
		Python:
	
	f=open("qwerty.txt","r")
y=[]
for line in f:
    x=line.split(',')
    for val in x:
       y.append(int(val))  # Here if float is stored in file then it cannot be typecasted to int.
for i in range(len(y)-1):    # Doing bubble sort
    for j in range(len(y)-i-1):
        if y[j]>y[j+1]:
            y[j],y[j+1]=y[j+1],y[j]
f.close()
f=open("output.txt","w")
f.write(str(y)[1:-1])
f.close()