Export output of sql in Excel using Query - oracle

I want to export outupt of sql query. But I dont want to do it manually like right click on output and then export. I want to export output in excel in specific directory.

Change filename_excel to
filename_excel = [my_directory name '_N' num2str(1) '.xlsx'];
where
my_directory = 'C:\some\directory\structure\';
Alternatively (though use the first solution if possible) you can go:
current_dir = cd;
cd my_directory;
filename_excel = [ name '_N' num2str(1) '.xlsx'];
writetable(Table,filename_excel,'Sheet', 3, 'Range','A5');
cd current_dir;
clear current_dir;
by #aybybtu

Related

How can I concat a defined variable in oracle?

I'm new in Oracle db and I'm working on script. So I trying to run a lot of scripts with a relative
var path and I have subfolder.
Folder A:
Folder A.Child-1
Folder A.Child-2
RunAll.sql
Folder A.Child-1:
Script 1
Script 2
I know we can define path var like:
define path='C:\Folder A.Child-1';
#&pathScr\RunAll.sql;
If I put a complete path for Eg: Script 1, the script can be exec. But is there any way to do something like:
define Scriptpath= Concat(&path, 'Folder A.Child-1')
#&Scriptpath\Script 1.sql;
So that I only need to declare the path only once.
What I tried:
define Scriptpath= concat(&path, 'Folder A.Child-1')
#&Scriptpath\Script 1.sql;
define Scriptpath= &path || 'Folder A.Child-1'
#&Scriptpath\Script 1.sql;
Declare Scriptpath:= = &path || 'Folder A.Child-1';
Begin
End;
#&Scriptpath\Script 1.sql;
All those trial return errors something like
Can not open file concat(&path, 'Folder A.Child-1')
You don't need concat, just use the same way with simple variable substitution in shell scripting:
SQL> def path1='mypath'
SQL> def path2='&path1/xyz.sql'
SQL> prompt &path1
mypath
SQL> prompt &path2
mypath/xyz.sql

Snakemake, how to change output filename when using wildcards

I think I have a simple problem but I don't how to solve it.
My input folder contains files like this:
AAAAA_S1_R1_001.fastq
AAAAA_S1_R2_001.fastq
BBBBB_S2_R1_001.fastq
BBBBB_S2_R2_001.fastq
My snakemake code:
import glob
samples = [os.path.basename(x) for x in sorted(glob.glob("input/*.fastq"))]
name = []
for x in samples:
if "_R1_" in x:
name.append(x.split("_R1_")[0])
NAME = name
rule all:
input:
expand("output/{sp}_mapped.bam", sp=NAME),
rule bwa:
input:
R1 = "input/{sample}_R1_001.fastq",
R2 = "input/{sample}_R2_001.fastq"
output:
mapped = "output/{sample}_mapped.bam"
params:
ref = "refs/AF086833.fa"
run:
shell("bwa mem {params.ref} {input.R1} {input.R2} | samtools sort > {output.mapped}")
The output file names are:
AAAAA_S1_mapped.bam
BBBBB_S2_mapped.bam
I want the output file to be:
AAAAA_mapped.bam
BBBBB_mapped.bam
How can I or change the outputname or rename the files before or after the bwa rule.
Try this:
import pathlib
indir = pathlib.Path("input")
paths = indir.glob("*_S?_R?_001.fastq")
samples = set([x.stem.split("_")[0] for x in paths])
rule all:
input:
expand("output/{sample}_mapped.bam", sample=samples)
def find_fastqs(wildcards):
fastqs = [str(x) for x in indir.glob(f"{wildcards.sample}_*.fastq")]
return sorted(fastqs)
rule bwa:
input:
fastqs = find_fastqs
output:
mapped = "output/{sample}_mapped.bam"
params:
ref = "refs/AF086833.fa"
shell:
"bwa mem {params.ref} {input.fastqs} | samtools sort > {output.mapped}"
Uses an input function to find the correct samples for rule bwa. There might be a more elegant solution, but I can't see it right now. I think this should work, though.
(Edited to reflect OP's edit.)
Unfortunately, I've also had this problem with filenames with the following logic: {batch}/{seq_run}_{index}_{flowcell}_{lane}_{read_orientation}.fastq.gz.
I think that the core problem is that none of the individual wildcards are unique. Also, not all values for all wildcards can be combined; seq_run1 was run on lane1, not lane2. Therefore, expand() does not work.
After multiple attempts in Snakemake (see below), my solution was to standardize input with mv / sed / rename. Removing {batch}, {flowcell} and {lane} made it possible to use {sample}, a unique combination of {seq_run} and {index}.
What did not work (but it could be worth to try for others in the same situation):
Adding the zip argument to expand()
Renaming output using the following syntax:
output: "_".join(re.split("[/_]", "{full_filename}")[1,2]+".fastq.gz"

The %procid% sometimes blank in rsyslog template

I'm trying to configure rsyslog to output in RFC5424 format. This means that the PROCID must be output in the syslog header. If there's no header, it should output a single dash (-) in its place. However, some of the events output have it just blank, and some have an actual value.
This is rsyslogd 5.8.10 running on Amazon Linux.
Here are the config lines:
$template CustomFormat,"<%PRI%>1 %timegenerated:1:23:date-rfc3339%-00:00 %HOSTNAME% %app-name% b%procid%b %msgid% %STRUCTURED-DATA%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
$ActionFileDefaultTemplate CustomFormat
Note that I put a "b" on each side of %procid% to make it more visible (this part is not RFC5424-compliant). Here are two lines of sample output.
<87>1 2019-06-19T20:03:01.929-00:00 ip-10-90-0-15 crond b29408b - - pam_unix(crond:account): expired password for user root (password aged)
<85>1 2019-06-19T20:17:18.150-00:00 ip-10-90-0-15 sudo bb - - ssm-user : TTY=pts/0 ; PWD=/ ; USER=root ; COMMAND=/bin/vi /etc/rsyslog.conf
The first line is correct, but the second example should have "b-b" instead of "bb". What should I do to make the blank %procid% show up as a dash? It works fine for the %msgid% and %STRUCTURED-DATA%.
Is there a better way to get RFC5424 output? (I have to use -00:00 instead of Z.)
There may be a better way, but one thing you can try is to use a Rainer script variable in the template instead of the property, and set this variable to "-" if the procid is empty. For example,
$template CustomFormat,"<%PRI%>1 ... b%$.myprocid%b ..."
$ActionFileDefaultTemplate CustomFormat
if ($procid == "") then {
set $.myprocid = "-";
} else {
set $.myprocid = $procid;
}
*.* ./outputfile
Just make sure the if statement is before any action statements. Note, you cannot change the procid property itself with set.

Laravel adds mysql in file path

I am facing a weird issue with Laravel 5.5. I am working on my local xampp server and trying to execute LOAD DATA INFILE query in controller function. But I am getting error PDOException (HY000)
SQLSTATE[HY000]: General error: 29 File 'D:\xampp\mysql\data\uploads\RDMST.csv' not found (Errcode: 2 "No such file or directory")
Currently my csv file is located at public/uploads folder. I tried various path settings for filename like
$fileCsv = 'uploads/RDMST.csv';
$fileCsv = public_path().'/uploads/RDMST.csv';
But I am getting same error and please notice the error path shows mysql\data in path. I am not getting from where it is appending this two folders in path. When I echo public path , it displays this:
D:\xampp\htdocs\tax\public
So, can you please help how to use path for load file without appending this "mysql\data" in path?
Any help is greatly appreciated.
Here is my complete controller function:
public function getCsv()
{
//echo public_path(); die;
//$fileCsv = public_path().'/uploads/RDMST.csv';
$fileCsv = 'uploads/RDMST.csv';
echo $query = "LOAD DATA INFILE '".$fileCsv."'
REPLACE
INTO TABLE tblreception
(year,
reception_number,
file_date,
file_time,
instrument_type,
#created_at,
#updated_at)
SET created_at=NOW(),updated_at=null";
DB::connection()->getPdo()->exec($query);
//return view('reception');
}
Can we not use csv file path?
Thanks

How to write an ini file with if conditions

I want to write an ini file with if else conditions that i parse it with ConfigParser in python.
How to use if and Else statements in ini File ??
If I understand what you're asking...
What you're probably looking to do is something like this:
Set the value of the conditions in the INI file...
[section_1]
condition_a = true
condition_b = false
condition_c = false
Read in the conditions' boolean values using getboolean()...
import ConfigParser
config = ConfigParser()
config.read('my_file.ini')
if config.getboolean('section_1', 'condition_a'):
# Run your first conditional code
if config.getboolean('section_1', 'condition_b'):
# Run your second conditional code
if config.getboolean('section_1', 'condition_c'):
# Run your third conditional code

Resources