xinchin
                
              
                
              
                  
                  
              1
              
             
            
              I’m trying to read a csv file into julia, e.g.
a,b,c
1,23,4
1, , 5
by using
CSV.File(csvfile, missingstring = " ", types = [Int, Int, Int])
but getting this
2-element CSV.File{false}:
 CSV.Row: (a = 1, b = 23, c = 4)
 CSV.Row: (a = 1, b = missing, c = missing)
the problem is the second line column c.
Also I couldn’t find the feature that it advertises (reading fixed width column)???
             
            
              
              
              1 Like
            
            
           
          
            
              
                erickn
                
              
              
                  
                  
              2
              
             
            
              Maybe you can try it without the missingstring option to see if that is what you want?
CSV.File(csvfile, types = [Int, Int, Int])
             
            
              
              
              
            
            
           
          
            
              
                lungben
                
              
              
                  
                  
              3
              
             
            
              
Could it be due to the leading space before the 5? This value starts with the missing string.
             
            
              
              
              
            
            
           
          
            
            
              In lack of better solution, you could remove all spaces while reading the csv file using this trick from @GunnarFarneback:
CSV.File(IOBuffer(replace(read(csvfile, String), " " => "")), missingstring = "", types = [Int, Int, Int])
             
            
              
              
              
            
            
           
          
            
              
                xinchin
                
              
              
                  
                  
              5
              
             
            
              This is very dangerous trick, it is wasteful too 
             
            
              
              
              
            
            
           
          
            
              
                xinchin
                
              
              
                  
                  
              6
              
             
            
              yes space before the 5 is the problem
this is MWE and removing missingstring option is not a solution.