2012-01-06 created by baoxinjin
一、摘要
讀寫csv的方式
1. 寫csv
step1. 建立測試目錄
step2. 寫csv檔案
step3. 檢視csv檔案
2. 讀csv
step1. 建立測試表
step2. 讀csv檔案
step3. 檢視表
二、寫csv檔案
step1. 建立測試目錄
--建立測試目錄
create
orreplace directory bxjcsv as
'/home/oracle/bxjcsv';
--目錄許可權分配
grant
read, write on directory bxjcsv to public;
step2. 寫csv檔案
declaref_emp utl_file.file_type;
cursor
cur_emp
isselect
first_name,last_name,email,phone_number,salary
from
hr.employees
where rownum<=10;
rec_emp cur_emp
%rowtype;
begin
f_emp :
=utl_file.fopen (
'bxjcsv
','emp_dept.csv
','w
',32767
);
for rec_emp in
cur_emp
loop
utl_file.put (f_emp, rec_emp.first_name);
utl_file.put (f_emp, ',
'||rec_emp.last_name);
utl_file.put (f_emp, ',
'||rec_emp.email);
utl_file.put (f_emp, ',
'||rec_emp.phone_number);
utl_file.put (f_emp, ',
'||rec_emp.salary);
utl_file.new_line (f_emp);
endloop;
utl_file.fclose (f_emp);
end;
step3. 檢視csv檔案
三、讀csv檔案
step1. 建立測試表
createtable
hr.bxj_employees (
first_name
varchar2(50
),last_name
varchar2(50
varchar2(100
),phone_number
varchar2(50
),salary
number
)
step2. 讀csv檔案
declaref_emp utl_file.file_type;
v_line
varchar2 (1000
); v_first_name hr.bxj_employees.first_name
%type;
v_last_name hr.bxj_employees.last_name
%type;
v_email hr.bxj_employees.email
%type;
v_phone_number hr.bxj_employees.phone_number
%type;
v_salary hr.bxj_employees.salary
%type;
begin
f_emp :
= utl_file.fopen ('
bxjcsv
', '
emp_dept.csv
', 'r'
);
ifutl_file.is_open (f_emp)
then
loop
begin
utl_file.get_line (f_emp, v_line,
1000
);
if v_line is
null
then
exit
;
endif
; v_first_name :
= regexp_substr (v_line,'
[^,]+
',1,1
); v_last_name :
= regexp_substr (v_line,'
[^,]+
',1,2
); v_email :
= regexp_substr (v_line,'
[^,]+
',1,3
); v_phone_number :
= regexp_substr (v_line,'
[^,]+
',1,4
);
v_salary :
= regexp_substr (v_line,'
[^,]+
',1,5
);
insert
into
hr.bxj_employees
values
(v_first_name,v_last_name,v_email,v_phone_number,v_salary);
commit
; exception
when
no_data_found
then
exit
;
end;
endloop;
endif;
utl_file.fclose (f_emp);
end;
step3. 檢視表
thanks and regards
非阻塞讀和寫版 TCP回顯C S
通過fcntl設定套接字,標準輸出,標準輸入為非阻塞 客戶端 include include include include include include include include include include define bufsize 4096 int max int a,int b...
Python基本讀和寫
f open r e out.txt w while true r input pls.enter strings if r exit break f.write r f.close 有open就一定要有close,且在同一級別縮行要相等 if判斷語句一定要有 這個是清空操作 結尾需要加exit結束...
sram的讀和寫
sram的型號 issi is61lv25616 10tl 以上是資料手冊上的。對sram的認識 sram不需要重新整理電路即能儲存它內部儲存的資料。而dram dynamic random access memory 每隔一段時間,要重新整理充電一次,否則內部的資料即會消失,因此sram具有較高的...