Tags » Csv

Read Comma Separated Files (CSV) from Linux Bash Script

Following example reads file users.csv and outputs the username to the output.

oldIFS=$IFS
IFS=$'\n'
for line in $( cat users.csv )
do
  user_name=${line%,*}
  echo $user_name
done
IFS=$oldIFS 35 more words
Linux

CSVReader PL/SQL + java

  • support on Oracle 10, 11, 12

1. Create java source with name CSVReader.

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "CSVReader" AS
import java.lang.*;
import java.io.File;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;

public class CSVReader {

// Procedure set encoding for Java = cp1251 (for situations where database character set is AL32UTF8), otherwise there not will be read Russian characters
public static void encod()
{
System.setProperty("file.encoding","cp1251");
}

// Procedure for filling the object type t_line (to display the data from csv file)
static void toLine (int pRowNum, String pValue, int pDelQoutes)
throws Exception {
encod();
#sql {
begin
csvreader.private_add_line (
p_row_nr        => :pRowNum,
p_value         => :pValue,
p_delqoutes     => :pDelQoutes );
end;
};
}

// Function replace all separator between double quotes
public static String replace_between_qoutes(String p_text, String p_sep)
throws Exception {
char sep = p_sep.charAt(0);
String copy = new String();
boolean inQuotes = false;
int code = (int) sep;
char dblq = '"';

for(int i=0; i<p_text.length();++i) {
if (p_text.charAt(i)=='"')
inQuotes = !inQuotes;

if (p_text.charAt(i)==sep && inQuotes)
copy += "chr("+code+")";

else
copy += p_text.charAt(i);
}
return copy;
}

// Procedure reading csv file from disk
public static void read(String p_file, Integer p_skip, Integer p_delqoutes)
throws Exception {
encod();
int             line_counter     = 1;
int             col_counter      = 0;
File            file        = new File(p_file);
BufferedReader  br          = null;
String          line        = "";
String          text        = "";

br = new BufferedReader(new FileReader(file));
// read line by line
while ((line = br.readLine()) != null) {
// skip lines when set to skiplines
if (line_counter > p_skip) {
// filling oracle type for display values
CSVReader.toLine(
line_counter,
line,
p_delqoutes
);
}
line_counter++;
}
}

};
/
… 890 more words
Oracle

Can you find the £883,000 in savings needed to keep Upton & West Kirby fire stations open?

Can you find the £883,000 in savings needed to keep Upton & West Kirby fire stations open?

As the consultation closes in the next few days on the issue of closing West Kirby and Upton fire stations and building a new fire station at Saughall Massie (the consultation closes on the 18th May 2015) I thought it would be useful to publish the list of payments over £500 made by the Merseyside Fire and Rescue Service over the past year. 489 more words

Wirral Council

Export Active Directory group members to CSV file using Powershell

This is something you’ve had to do multiple times and you’re tired of looking up how to do it each time. Why won’t your damn brain work? 52 more words

Creating Shared Value: Doing well by doing good!

Relevant research has shown that those companies that had undertaken social and environmental responsibility did prosper in the long run (McWilliams and Siegel, 2001; Orlitzky, 2003). 498 more words

Corporate Social Responsibility

Concatenate rows into CSV

If you have the need to take multiple rows into 1 comma separated row then this should do the trick. One of the biggest usages for this is when you’re using SSRS with multiple parameters. 20 more words

SQL

What are the different tables(Engine) present in MySQL, which one is default?

Following tables (Storage Engine) we can create :

1. MyISAM (Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type. 212 more words

MySQL