s******8 发帖数: 102 | 1 if your SAS is 64bit 9.3, but you MS is 32 bit, you need download 'SAS PC
files server' and install it.
then dbms=exclecs like:
if there is a file ="&outpath.\&outfile..xls then,
proc export data=yourdata
outfile="&outpath.\&outfile..xls" dbms=excelcs replace;
run;
if there is not a file ="&outpath.\&outfile..xls then
proc export data=yourdata
outfile="&outpath.\&outfile..xlsb" dbms=excelcs replace;
run; |
|
l*********r 发帖数: 674 | 2 小弟初学shell scrip,请多指教。
手头上有个很长的文件,里面存储的类似于邻接表数据,现在希望构造整个表。比如输
入文件 tmp:
1 2 3
4 5 6 7
输出outfile:
1 2
1 3
4 5
4 6
4 7
请问怎么用shell srcipt实现呢?
我试了以下的语句,读取每一行作为line,但是不知道怎么提取每一个元素:比如对于
第一行line=1 2 3, 我用a=${line[0]},希望a=1, 但是返回的$a总是一整行。
processLine(){
outfile="outfile"
line="$@"
count=`echo $line | wc -w`
a=${line[0]} # line[0] always refers to the whole line
for ((i=1; i< count; i++))
do
echo -n $a >> $outfile
echo ${line[$i]} >> $outfile
done
}
### Main script stars here ###
FILE="$1"
# S |
|
w********0 发帖数: 1211 | 3 非常感谢sunnyedinken, jyjyjjyy, binrose,现在编译倒是通过了,无论是加上using std::fstream, 或者整个
的using namespace std都行。但新问题又来了,运行起来打不开文件。
我照着Lippman那本书写的:
ofstream outfile;
outfile.open("test.txt");
if (!outfile) {
cerr << "error: unable to open output file: \n ";
}
outfile.close();
运行起来总是告诉我 error: unable to open output file:
也就是文件根本就没打开。
我尝试着建立一个文件放在目录里(和source,header同一个目录下) ,也没用。
ifstream,ofstream都不行。
也尝试过定义的时候直接bind: ofstream outfile("test.txt"), 还是不行。
看来我实在太弱了。
********************... 阅读全帖 |
|
w********0 发帖数: 1211 | 4 非常感谢你们几位,现在编译倒是通过了,无论是加上using std::fstream, 或者整个
的using namespace std都行。但新问题又来了,运行起来打不开文件。
我照着Lippman那本书写的:
ofstream outfile;
outfile.open("test.txt");
if (!outfile) {
cerr << "error: unable to open output file: \n ";
}
outfile.close();
运行起来总是告诉我 error: unable to open output file:
也就是文件根本就没打开。
我尝试着建立一个文件放在目录里(和source,header同一个目录下) ,也没用。
ifstream,ofstream都不行。
也尝试过定义的时候直接bind: ofstream outfile("test.txt"), 还是不行。
看来我实在太弱了。 |
|
B*****g 发帖数: 34098 | 5 你不会python为啥非要用python?
import sys
infile = open(sys.argv[1], 'r')
v_list = []
d_list = []
for line in infile.readlines():
w_list = line.rstrip('n').split(' ')
if w_list[0] == '_a_':
v_list.append(w_list[1])
d_list.append(w_list[2])
infile.close()
outfile = open(sys.argv[2], 'w')
outfile.write(', '.join(v_list) + '\n')
outfile.write(', '.join(d_list) + '\n')
outfile.close() |
|
z********i 发帖数: 568 | 6 /* find the first missing postivie integer in array A with n elements
return x if one postive integer in [1..n] is missing;
return 0 otherwise;
*/
int findFirstMissingPositiveInteger(int A[], int n){
int x,i,val,index;
/* rearrange the input array A such that
B[i]=i+1 if i+1 exist in array A, or
B[i]=A[i] if i+1 does not exist in array A
where B is the array rearraged from A.
*/
for(i=0;i
/* put A[i] in A[A[i]-1] if 1<=A[i]<=n && A[i]!=i+1 */
val=A[i... 阅读全帖 |
|
z********i 发帖数: 568 | 7 /* find the first missing postivie integer in array A with n elements
return x if one postive integer in [1..n] is missing;
return 0 otherwise;
*/
int findFirstMissingPositiveInteger(int A[], int n){
int x,i,val,index;
/* rearrange the input array A such that
B[i]=i+1 if i+1 exist in array A, or
B[i]=A[i] if i+1 does not exist in array A
where B is the array rearraged from A.
*/
for(i=0;i
/* put A[i] in A[A[i]-1] if 1<=A[i]<=n && A[i]!=i+1 */
val=A[i... 阅读全帖 |
|
f*******r 发帖数: 976 | 8 题目就是external sort的思想。统计单词的次数,明显用map。注意文
件很大,要用long,以免溢出。
在你读文件并且增加这个map时,内存不够用,这是你要把临时结果写入临时文件。你
可以设计一个threshold,比如1 billion,当map的size达到这个值时,你就把map和临
时文件merge到另一个临时文件里。最后再把这个文件rename到原来的临时文件。再把
map清空,继续读原文件直到结束。 C++代码如下:
// Split the string into words that consists of a..z and A..Z.
void split(const string &s, vector &res) {
int beg = -1;
for (int i = 0, e = s.size(); i < e; ++i) {
if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z')) {
if (beg == ... 阅读全帖 |
|
s*****0 发帖数: 357 | 9 SAS wasn't meant to handle this type of long record, and I think that SAS is
not a good option. Run the following perl code in a Unix system and use the
resulted txt file for your SAS.
use strict;
use warnings;
my $filename = "directory/sourcefilename.txt";
my $outfile = "directory/outputfilename.txt";
open (OUTFILE, ">$outfile") or die ("Cannot write to the target file!!!\n");
open (INFILE, $filename) or die ("Cannot open the target file!!!\n");
my $line = ;
my @numList = split (',', $l |
|
A******u 发帖数: 1279 | 10 这个算编程吗?
#!/bin/bash
# Author: Amorphou
# Oct 2010
# grepfwd $pattern $infile $linenumber1 $linenumber2 $outfile
# for each occurence of a pattern, grep forward by $linenumbers
# Without a 5th arg, save to files fwdgrep.$int by default
# defaults
((linenumber1=0))
((linenumber2=0))
FILES="fwdgrep"
SED=/bin/sed
if [ "$#" -lt "2" -o "$#" -gt "5" ]
then
echo "USAGE: $0 pattern infile linenumber1 linenumber2 [optional]outfile"
exit 0
fi
if [ "$#" -ge "3" ]
then
if echo "$3" | grep "^[0-9]*$"... 阅读全帖 |
|
H********g 发帖数: 43926 | 11 升级版,可以读取命令行输入了
#csv2xls.pl
#>csv2xls.pl abcd.csv
#generages abcd.xls
use strict;
use warnings;
use Text::CSV;
use Spreadsheet::WriteExcel;
my $infile="test.csv" ;
if($ARGV[0]){$infile=$ARGV[0];}
my $basename=$infile;
$basename=~s/.csv//i;
my $outfile="$basename.xls";
my @rows;
my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attribute.
or die "Cannot use CSV: ".Text::CSV->error_diag ();
open my $fh, "<:encoding(utf8)", $infile or die "$infile: $!";
my $rowcount=... 阅读全帖 |
|
g*****u 发帖数: 298 | 12 【 以下文字转载自 Programming 讨论区 】
发信人: grasssu (黄底黑花纹的猫), 信区: Programming
标 题: C++如何在linux上生成并使用超过2GB的大文件?
发信站: BBS 未名空间站 (Sun Aug 13 22:35:27 2006)
我的C++程序大概是:
ofstream outFile("file");
for(long i = 0; i< VERY_LARGE_NUMBER; i++)
outFile<<"something";
编译时使用了-DLINUX -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_
LARGEFILE64_SOURCE , 可是当超过2G时还是出错结束:
filesize limit exceeded.
程序在windows上运行正常。
谁知道怎么解决?谢谢。 |
|
w****w 发帖数: 521 | 13 Memory够的话,hash一下就出来了。不够的话得分批。
#!/usr/bin/env python
smallfile = file("small.txt","r")
largefile = file("large.txt","r")
outfile=file("out.txt","w")
HASHSIZE=10*1024*1024
maxvalue=0
hash={}
while 1:
line=largefile.readline()
if not line:
break
v=int(line.strip())
if v>maxvalue:
hash={}
while 1:
r=smallfile.readline()
if not r:
break
maxvalue=int(r.strip())
hash[maxvalue]=1
if le... 阅读全帖 |
|
r*****o 发帖数: 28 | 14 What if I want to use the matching variable as an index of an array?
What I wanted to do is:
infile:
SRC_1
SRC_2
SRC_3
SRC_4
SRC_5
change it to outfile:
SRC_2
SRC_3
SRC_4
SRC_1
SRC_5
(Ultimately, I will want to try all the possible sequences of
SRC_1 to SRC_5
So what I did:
set array = (2 3 4 1 5) #this array can be changed by script automatically
sed "/SRC_[1-5]/s/\([1-5]\)/$array[\1]/" infile > outfile
But it doesn't recognize \1 as the index of the array,
anyway to solve it? Thanks.
variab |
|
P**********c 发帖数: 17 | 15 试试
PROC EXPORT DATA=output1 DBMS=EXCEL OUTFILE="...\output.xls" REPLACE;
SHEET=output1;
RUN;
PROC EXPORT DATA=output2 DBMS=EXCEL OUTFILE="...\output.xls" REPLACE;
SHEET=output2;
RUN;
..... |
|
l****u 发帖数: 199 | 16 要输出,used下列CODES:
不WROK method1:
proc export data=febdaily06 outfile='H:\death\test.xls' replace;
run;
ERROR: The target file contains unmatched range name and sheet name. You may
use other name or remove the unmatched range/sheet in the file.
不WROK method1:
尝试了最笨的方法:EXPORT,不WORK。
ERROR: Error attempting to CREATE a DBMS table. ERROR: Execute: ????????.
WORK的 method1:
proc export
outfile = "H:\death\test.dbf"
data = febdaily06
dbms = dbf replace;
run;
WORK的 method2:
ods csvall file="H:\d |
|
m**********n 发帖数: 34 | 17 Hope it helps.
You need to use PROC PRINTTO before PROC REPORT,
then put your PROC REPORT code as it is, followed by PROC PRINTTO.
After that is done, you use DATA step to read in this OUTFILE,which would be
your original OUTPUT file if you only use PROC REPORT.
Let me know if you have any questions.
proc printto new print=outfile; run;
PROC REPORT DATA=final_date NOWD HEADLINE HEADSKIP MISSING SPLIT='|' SPACING
=1;
COLUMN ("| | MY TITLE HERE |With ALL Available Sites | |-- "
|
|
h******e 发帖数: 1791 | 18 请给看看以下code为什么把结果打在了log里而不是指定文件?
outfile已经设好,没问题。
string是dataset report里需要输出的变量。
proc printto new print = outfile; run;
data _null_;
set report;
put @1 string $char134.;
run;
proc printto; run; |
|
h******e 发帖数: 1791 | 19 no, outfile has been set:
filename outfile "&outpath.&fname..txt"; |
|
t*****w 发帖数: 254 | 20 outfile="C:/Users/CareerChange/My Documents/one.csv"
should be: outfile="C:\Users\CareerChange\My Documents\one.csv" |
|
k*****8 发帖数: 91 | 21 想把两个数据放入同一个Excel的不同工作簿里面。用了两种方法但是都是第二个
dataset把之前的一个dataset覆盖了(i.e.output里面只有demog这个dataset)。请问
这是什么原因?还有什么其他的方法能够实现在一个Excel里面建立多个工作簿?
data test demog;
input id $ sex $ age;
if sex='f' then output test;
else output demog;
datalines;
001 f 9
394 m 10
204 f 20
395 f 3
;
run;
/*Method 1*/
ods listing close;
ods tagsets.excelxp file="c:\temp\test4.xml" style=minimal;
ods tagsets.excelxp options(Sheet_Name='Class Data');
proc print data=test;
run;
ods tagsets.excelxp options(Sheet_Name='Demog Data');... 阅读全帖 |
|
e*****e 发帖数: 263 | 22 问题是这花旦扮相不配合剧情人物啊
还有就是那身OUTFIL设计的简直就是一个臃肿的老大妈形象
完全没有神态气质可言
谢雪心,不知道是哪个
这里面演大奶奶的那个以前从来没见过,但是很漂亮高贵 !
衣服也很华丽 |
|
a****a 发帖数: 3411 | 23 同郁闷
outfile +'\n'
也不给换行。。。 |
|
kx 发帖数: 16384 | 24 Python 2.5: C:\Python25\pythonw.exe
Thu May 06 02:12:17 2010
A problem occurred in a Python script. Here is the sequence of function call
s leading up to the error, in the order they occurred.
C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserv
er.py in _HandleRequest(self=
verRequestHandler instance at 0x019A72B0>)
3190 outfile = cStringIO.StringIO()
3191 try:
3192 se |
|
o*******e 发帖数: 31 | 25 How to output the selected table records into a file?
I try to use:
SELECT * FROM MY_TABLE INTO OUTFILE 'out.txt'
FIELDS TERMINATED BY ',';
But the error msg told me access denied. The default
path is the current directory for the output file?
What kind of permission is expected to be set for the
directory? How about if the file is already there, do
I need to del first?
never use MySQL b4.
Thanks for help. |
|
M*P 发帖数: 6456 | 26 不知道你在干嘛,后几列可以这么干
awk -F'\t' '{print $7 $8 $9}' yourfile > outfile
t\
8 |
|
b*******g 发帖数: 513 | 27 如何在linux中用a2ps merge 两个 eps figures?不知道有没有谁用过这个?我试了这句命令:
a2ps -o outfile.eps 1.eps 2.eps
去merge两个eps figures, 1.eps and 2.eps.
但就是不知道怎么,总有错,得到的总eps figure,只有原来的一个figure,我的意思是把两个figures放到一个图里。这是为什么?我语句用错了吗?
多谢大虾指点! |
|
c******e 发帖数: 56 | 28 遇到一个麻烦事,原来写的是subroutine,和主程序在同一个文件, 现在要把sub转到
一个module里去。总是不成功,求教。 例程如下:
@var3_array_out=();
mySubTest(\@var1_array_in, $var2_scale_in, \@var3_array_out);
for ($j=1; $j<=100; $j++){
printf outfile $j."\t".$var3_array_out[$j]."\n";
}
...
sub mySubTest{
my($var1_array_in, $var2_scale_in, $var3_array_out) = @_;
my($i, $j, $k);
my(@var1_array)=@{$var1_array_in};
my(@var3_array)=@{$var3_array_out};
...
@{var3_array_out} = @var3_array;
}
我是直接把mySubTest拷贝到myModule.pm里面,然后在主程序里面调 |
|
p**o 发帖数: 3409 | 29 open(outfile,'w').write(open(infile).read().replace('|', ',')) |
|
n******1 发帖数: 3756 | 30 【
my $infile = "2.txt";
my $infile2 = "1.txt";
my %MAP;
open(IN, "<$infile") or die "\n\nNADA $infile you FOOL!!!\n\n";
my @DATA = ;
#write in a hash map
foreach my $line (@DATA)
{
chomp($line);
my @data = split('\s', $line);
chomp($data[0]);
chomp($data[1]);
$MAP{$data[0]}=$data[1];
}
#print the hash map
for my $key (keys %MAP){
my $value = $MAP{$key};
print "$key => $value\n";
}
close(IN);
#2. search
open(IN, "<$infile2") or die "\n\nNADA $infile you FO... 阅读全帖 |
|
发帖数: 1 | 31 下面这个方法试了试,也不行
i=0
with open(inputFileName,'rb') as infile, open(outputFileName,'wb') as
outfile:
for r in infile.readlines():
if i/2==1:
for var in r.values():
print r.values()
if eval(var).isdigit():
list(var).replace('"','')
i=i+1 |
|
b*******g 发帖数: 513 | 32 如何在linux中用a2ps merge 两个 eps figures?不知道有没有谁用过这个?我试了这
句命令:
a2ps -o outfile.eps 1.eps 2.eps
去merge两个eps figures, 1.eps and 2.eps.
但就是不知道怎么,总有错,得到的总eps figure,只有原来的一个figure,我的意思
是把两个figures放到一个图里。这是为什么?我语句用错了吗?
多谢大虾指点! |
|
c*****t 发帖数: 1879 | 33 /* a code I wrote long time ago for this purpose */
#include
#include
#include
#include
#include
#include
#ifndef true
#define true 1
#define false 0
#endif
int Error (char *);
long filelength (FILE *f)
{
register long size, pos = ftell (f);
fseek (f, 0, SEEK_END);
size = ftell (f);
fseek (f, pos, SEEK_SET);
return size;
}
int writefile (FILE *infile, char *filename, long filesize)
{
FILE *outfile;
char buffer[409 |
|
D**e 发帖数: 10169 | 34 if you know the dimension of the matrix, it's easy. suppose it's MxN. and M/N
is not too large.
tail -n M infile | awk '{printf "%d %d ... %d\n", $1, $2, ..., $n}' > outfile |
|
z**w 发帖数: 69 | 35 the number of columns of the matrix is not constant.
how can I retrieve this number from "wc -l"?
or is there any options of "tail" to take the all the contents starting
from line 16?
thanks..
M/N
outfile |
|
z****c 发帖数: 6 | 36 man at 时发现有这个例子:
$ at -m 0730 tomorrow
sort < file >outfile
是什么意思?end of tape? 在这里有什么用?还有键入第一行
at -m 0730 tomorrow 后出现 at> 的提示符状态,又是什么意思?如何退出
这个提示符状态?
太土了! |
|
t***s 发帖数: 30 | 37 My script tries to open a very large file, 3GB in size and fails with an error
like:
a slow, suffocating death: Value too large for defined data type at
../scripts/invcsplit.pl line 156.
Part of the script is:
open (INFILE, "<$filename") or die "a slow, suffocating death: $!";
open (OUTFILE,">".$segment.$filename);
while ()
{
$line=$_;
....
Any suggestion would be really appreciated. Thank you! |
|
i********f 发帖数: 206 | 38 有人用这个BLAST+的新版本么?
里面-entry和-entry_batch的参数是怎么设的?
-entry除了all可以用,自己输序列名字,好像不行啊。
序列
>chr01
CCCTAAACCCTAAACCCTAAACCCTAAACCTCTGAATCCTTAATCCCTAAATCCCTAAATCTTTAAATCCTACATC
CAT
命令行:
blastdbcmd -db SEQ -dbtype nucl -entry chr01 -range 70-75 -strand plus -out
outfile
这个报错BLAST query/options error: No valid entries to search
有人碰见类似问题的么?多谢 |
|
j******y 发帖数: 180 | 39 outfile.open("xxx") will search the local directory for xxx. If exists, it
will be successful, else it will create a new one. Then you can run your code
successfully. The only possible issue is the directory does not exists or you do not have the privilege to create.
So, no problem with your code.
If you are under linux, use chmod to make writable. |
|
l***a 发帖数: 12410 | 40 how does this work if you want txt file
proc export data='' outfile='...txt' dbms=csv
User\ |
|
y****1 发帖数: 400 | 41 新尝试如下:
proc export data=Imp.pedfile outfile='C:\Documents and Settings\User\My
Documents\Imputation paper\Chr21ped.txt' dbms=csv;
run;
这个是work的,可是非常让我不解的是我明明有5+16179=16184列,从第6列开始一直到
最后一列的这
16179列中,每一列都有2个数字(1或2),我成功输入到txt文件中后也是24行,可是
我把第一行粘到word
中word count的时候就只有16383个character了???为什么呢???
我现在非常非常的confuse,我都不知道16383这个数字是怎么来的。难道txt文档每行
的长度有限制?
最后还是多谢大家的关注! |
|
b*******g 发帖数: 513 | 42 Or try this:
filename cc "path.\xx.csv";
PROC EXPORT DATA=dataset1 OUTFILE=cc DBMS=CSV REPLACE;
run;
文件也行。
件。 |
|
d*******1 发帖数: 854 | 43 比如你的SAS文件叫test.
data test;
a=1;b=1; output;
a=2;b=2; output;
run;
用下面的code, SAS-> CSV-> SAS-> 加# -〉CSV
proc export data=test
outfile='c:\test.csv' replace;
run;
data testx;
infile 'c:\test.csv' truncover;
input raw $1-100;
run;
data testx;
set testx;
if _n_=1 then raw='#'||trim(left(tranwrd(raw,',',',#')));
run;
data _null_;
set testx;
file 'c:\testx.csv' dlm='09'x;
put raw;
run; |
|
t**********h 发帖数: 100 | 44 How to create macro variable in xls file? I mean it automatically update xls
file to today’s date or this current such as:
proc export data = files
outfile = "c\filename&week.xls" dbms = xls replace ;
run;
thanks. |
|
c****g 发帖数: 156 | 45 DATA _NULL_;
call symput ('today', compbl(put(today(), date9.)));
run;
proc export data = files
outfile = "c:\filename&today." dbms = xls replace ;
run; |
|
P****D 发帖数: 11146 | 46 proc export data = files
outfile = "c:\filename&sysdate9." dbms = xls replace ;
run;
Don't need any DATA step before it. |
|
R*******c 发帖数: 249 | 47 只是call,R中的结果可以写到xls或者其他文件中,然后让matlab再读取
请问system怎么用呢?
我在网上搜过,有人建议用:system('R CMD BATCH infile outfile');但是我试过,
不行 |
|
B******5 发帖数: 4676 | 48 我刚在ubuntu上试了,可以的。
你的outfile是做什么的? |
|
b**********i 发帖数: 1059 | 49 get file = "directory\original_file.sav".
sort cases by id.
aggregate outfile = "directory\aggregated_file.sav"
/break = id
/new_group_mean_var = mean(old_var).
match file = *
/table = "directory\aggregated_file.sav"
/by = id.
把目录改到你的工作目录下,文件名存为你想要的文件名。引号要用英文下,我这里打
的不对。具体查看syntax command agregate procedure help |
|
R******d 发帖数: 1436 | 50 这个宏凑合看看吧
%macro pgxofy(filein=,flag=(Page x of y),append=N,outfile=,ls=132)/des='Page
x of y';
*以&flag为标识算总页数;
data _null_;
retain pg 0;
infile "&filein" end=last;
input;
if index(upcase(_infile_),"&flag") then do;
pg=pg+1;
end;
if last then call symput("totpg",put(pg,4.0));
run;
*将&flag标识替换为“page X of Y”;
data tttttttt;*(keep=text);
length text2 text $200.;
retain pg 0;
infile "&filein";
input;
if index(upcase(_infile_),"&flag") the |
|