Write a CSV class

Closed Posted 6 years ago Paid on delivery
Closed Paid on delivery

# Write a CSV parser that handles complex files without using the standard library.

# A standard CSV has fields separated by commas and rows separated by newlines. It may

# also have fields wrapped in quotes. Your CSV parser needs to handle quoted fields that

# may contain delimiter and newline characters.

# Spec (based on [login to view URL]):

# - The parser should return an array of arrays, one array for each row of the CSV file.

# - Rows are delimited by the newline character ("\n").

# - Each column is divided by a separator character (default ",").

# - Empty fields are valid.

# - Likewise, an empty row is still valid, and effectively contains a single empty field.

# - Uneven rows are valid.

# - A quoted field starts and ends with the same character (default '"'), and every

# character in between makes up the field value, including delimiters and newlines.

# - Quoted fields start immediately following a separator character, newline,

# or start of the file.

# - A quote character within a quoted field must be escaped by preceding it

# with another quote character.

# - Throw an error on unclosed quoted fields (or stray quotes inside fields).

# - Write tests that test your parser against the above spec.

# - Benchmark your solution.

class CSV

def [login to view URL](*); end

end

# Examples:

# Expected: [['a', 'b', 'c'], ['d', 'e', 'f']]

print [login to view URL]("a,b,c\nd,e,f"), "\n"

# Expected: [["one", "two wraps,\nonto \"two\" lines", "three"], ["4", "", "6"]]

print [login to view URL]("one,\"two wraps,\nonto \"\"two\"\" lines\",three\n4,,6"), "\n"

# Expected: [['alternate', '"quote"'], [''], ['character', 'hint: |']]

print [login to view URL]("|alternate|\t|\"quote\"|\n\n|character|\t|hint: |||", "\t", "|"), "\n"

# Expected: "Argument error: unclosed quote"

begin

print [login to view URL]('"dog","cat","uhoh'), "\n"

rescue ArgumentError => e

puts "ArgumentError: #{e}"

end

Algorithm Ruby Software Testing

Project ID: #15232896

About the project

4 proposals Remote project Active 6 years ago

4 freelancers are bidding on average $96 for this job

mrherkar

hello, what programming language do you need? How you mean this: without using the standard library. Relevant Skills and Experience 30+ years programming and Excel, my own CSV Serializer, from C# class to CSV Propose More

$333 USD in 25 days
(0 Reviews)
0.0
pugachev

Hello, I am new on the site, but I have wide experience in java development, and I can do what you need on java Relevant Skills and Experience 1 Proposed Milestones $100 USD - 1 e

$15 USD in 1 day
(1 Review)
0.0
nitzanfarhi

A proposal has not yet been provided

$15 USD in 1 day
(0 Reviews)
0.0