Showing posts with label CSV. Show all posts
Showing posts with label CSV. Show all posts

Julia language, read delimited files (CSV) with "readdlm"

 

When trying to execute:


wikiEVDraw = readdlm("wikipediaEVDraw.csv", ',') # getting quotes right is important!



I get the following error:

UndefVarError: readdlm not defined.


help?> readdlm search: readdir Couldn't find readdlm Perhaps you meant readdir, read, read!, real or readchomp No documentation found. Binding readdlm does not exist.


In this case use:

using DelimitedFiles wikiEVDraw = readdlm("wikipediaEVDraw.csv", ',') # getting quotes right is important! 



As an Amazon Associate I earn from qualifying purchases.

Julia language, read delimited files (CSV) with "readdlm"

 

When trying to execute:


wikiEVDraw = readdlm("wikipediaEVDraw.csv", ',') # getting quotes right is important!



I get the following error:

UndefVarError: readdlm not defined.


help?> readdlm search: readdir Couldn't find readdlm Perhaps you meant readdir, read, read!, real or readchomp No documentation found. Binding readdlm does not exist.


In this case use:

using DelimitedFileswikiEVDraw = readdlm("wikipediaEVDraw.csv", ',') # getting quotes right is important! 



As an Amazon Associate I earn from qualifying purchases.

Python UnicodeDecodeError



When you are reading CSV file (spreadsheet), make sure you set encoding="utf-8", or you might get:

UnicodeDecodeError: 'utf-8' codec can't decode byte
(result, consumed) = self._buffer_decode(data, self.errors, final)



def read_rows(CSV_file_path: str):
 
    import sys
    print("default encoding", sys.getdefaultencoding())
    import csv
    rows = []
    with open(CSV_file_path, 'rt', encoding="utf-8") as csvfile:
        cvs_reader = csv.reader(csvfile, delimiter=',', quotechar='"')
        for row in cvs_reader: # row is a list
            rows.append(row)
    return rows


As an Amazon Associate I earn from qualifying purchases.

Python UnicodeDecodeError



When you are reading CSV file (spreadsheet), make sure you set encoding="utf-8", or you might get:

UnicodeDecodeError: 'utf-8' codec can't decode byte
(result, consumed) = self._buffer_decode(data, self.errors, final)



def read_rows(CSV_file_path: str):
 
    import sys
    print("default encoding", sys.getdefaultencoding())
    import csv
    rows = []
    with open(CSV_file_path, 'rt', encoding="utf-8") as csvfile:
        cvs_reader = csv.reader(csvfile, delimiter=',', quotechar='"')
        for row in cvs_reader: # row is a list
            rows.append(row)
    return rows


As an Amazon Associate I earn from qualifying purchases.

Java: Chicago Public Salary Analyzer



Visit page and take a look at the data:

https://data.cityofchicago.org/Administration-Finance/Current-Employee-Names-Salaries-and-Position-Title/xzkq-xp2w

Download data as CSV (Commas Separated Values) which is used commonly to import-export spreadsheet type of data.

Create a new IntelliJ IDEA Module:

  • Maven project
  • GroupID: edu.clcillinois.cit137
  • ArtifactId: chi_pub_salary_analyzer
  • Module name chi_pub_salary_analyzer
If you see Notification: "Maven projects need to be imported"
  • Enable Auto-Import

Create Main class







Create package data.reader

Reader



TextFileReader




Create new Package "data.parser"

Create new Interface Parser in which we will outline methods we want to GET our data:


CVSParser




Writer




CSVWriter





As an Amazon Associate I earn from qualifying purchases.

Java: Chicago Public Salary Analyzer



Visit page and take a look at the data:

https://data.cityofchicago.org/Administration-Finance/Current-Employee-Names-Salaries-and-Position-Title/xzkq-xp2w

Download data as CSV (Commas Separated Values) which is used commonly to import-export spreadsheet type of data.

Create a new IntelliJ IDEA Module:

  • Maven project
  • GroupID: edu.clcillinois.cit137
  • ArtifactId: chi_pub_salary_analyzer
  • Module name chi_pub_salary_analyzer
If you see Notification: "Maven projects need to be imported"
  • Enable Auto-Import

Create Main class







Create package data.reader

Reader



TextFileReader




Create new Package "data.parser"

Create new Interface Parser in which we will outline methods we want to GET our data:


CVSParser




Writer




CSVWriter





As an Amazon Associate I earn from qualifying purchases.

apt quotation..