a***r 发帖数: 420 | 1 我有一个n*m的dataset,里面的信息是两个没有顺序的字母,ie.A B,B C,C B...
因为dataset很大,打算用C++处理,有个基础问题,网上教程老看不明白,
就是如何建立一个string的array?
比如在把这些信息存入C++的array时,我现在是建了一个三维的char数组,可否/如何
直接建立一个
string的二维数组呢?
如果上面这个问题成立,即如果可以有string的数组
有什么好办法可以把一个string分成指定大小,存入指定长度的string的数组呢?
比如我为了sql方便,把每行的m个col合成一个field
相当于成了一维的string数组
然后我在mysql里面sort啥的完了
用getline(cin,line),重新读入c++的二维数组,这时我希望把这个field按两个两
个放到
string的array里,但是getline似乎没有相应的命令,或者,我应该在合成field的时
候,就在每
两个字母间加个delimiter,然后用getline(cin,line,delim)?
另外,从generally的来说,string,是不是可以完全... 阅读全帖 |
|
|
s*****c 发帖数: 753 | 3 This symbol is ascii code 12, or form feed. \f
Try to use dlmread with ',\f' as delimiter. |
|
s*****c 发帖数: 753 | 4 This symbol is ascii code 12, or form feed. \f
Try to use dlmread with ',\f' as delimiter. |
|
h****r 发帖数: 117 | 5 Personally, I think the better way to type Latex nowadays is to use Scientific
Word (SW) or Workplace (SWP) 4.0 (or up). SWP has SW, style editor, and
computing ability.
I bought Winedt and used it for about one year. It is fun to play with Winedt.
It has a lot of good features, such as delimiter checking, on-screen spelling
check, Greek/Math typing interface, project manager, highly customizable menu
and toolbars. Also advanced users can write their own macros.
It is true that writing Latex man |
|
y**x 发帖数: 117 | 6 我要读出如下的一个文本文件:
start file------------
NA
3,4
1,2
end of file-----
我的MATLAB CODE 是:
fid=fopen('tsdata.txt');
ts=textscan(fid,'%f%f%f%f','CollectOutput',1,'treatAsEmpty',{'NA'},'
Delimiter',',');
fclose(fid);
>> ts{:}
ans =
NaN NaN NaN NaN
3 4 NaN NaN
1 2 NaN NaN
可是我真实想要的data is following:
ans =
NaN NaN NaN NaN
NaN NaN NaN NaN
3 4 NaN NaN
NaN NaN NaN NaN
1 2 NaN NaN
就是说,我要空白行都读出来。有哪位大牛知道方法吗?谢谢了先。 |
|
R***U 发帖数: 1860 | 7 I have a cell array that contain strings in matlab.
[Quan, Vol] = textread('test.bat', '%s %d',-1,'delimiter',',');
How can I change the value in one cell??
I try yo use
Quan(i)='Group1';
It doesn't work?
Thanks, |
|
s**a 发帖数: 8648 | 8 The Thunder of History:
Taxation in Comparative and Historical Perspective
May 4-5, 2007
Northwestern University
http://www.tgs.northwestern.edu/facultyandstaffinfo/facultyconferences/thunder/
Taxes define durable structures of inequality, delimit the capacities of the
state, and affect social behaviors from marriage to philanthropic giving.
Conflict over taxation has been a driving force in history from the French
and American Revolutions to the tax cuts of the George W. Bush
administration, an |
|
|
y******8 发帖数: 40 | 9 File “abcd” is a space-delimited file, and contains the following columns
of information:
Column 1: Name. Column 2: 1 - took test, 0 - didn’t. Column 3: Score.
Column 4: Date.
Contents of file “abcd”:
TED 1 75.5 01/01/2000
TED 1 80.1 01/02/2000
TED 0 00.0 01/03/2000
TED 1 45.5 01/04/2000
TED 1 94.7 01/05/2000
JON 1 88.1 01/01/2000
JON 1 65.1 01/02/2000
JON 0 00.0 01/03/2000
Contents of file “xyz”:
MOST PASSED TESTS
We want to find out who took the most tests with a grade... 阅读全帖 |
|
y**x 发帖数: 117 | 10 【 以下文字转载自 EE 讨论区 】
发信人: yksx (海云天), 信区: EE
标 题: matlab 问题请教:读出空白行
发信站: BBS 未名空间站 (Tue Aug 16 05:01:30 2011, 美东)
我要读出如下的一个文本文件:
start file------------
NA
3,4
1,2
end of file-----
我的MATLAB CODE 是:
fid=fopen('tsdata.txt');
ts=textscan(fid,'%f%f%f%f','CollectOutput',1,'treatAsEmpty',{'NA'},'
Delimiter',',');
fclose(fid);
>> ts{:}
ans =
NaN NaN NaN NaN
3 4 NaN NaN
1 2 NaN NaN
可是我真实想要的data is following:
ans =
NaN NaN NaN NaN
NaN NaN NaN NaN
... 阅读全帖 |
|
l******9 发帖数: 579 | 11 【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: error of opening a file located in a remote server from pyton
发信站: BBS 未名空间站 (Sun Jul 27 19:03:52 2014, 美东)
I need to access read a csv file located in a server from python 3.2 on win7.
The file name is
csv_file =
file_loc = '\serverName.myCompanyName.com\mypath\Files\myfile.csv'
with open(file_loc , 'r') as csv_file # error !!!
csv_reader = csv.reader(csv_file, delimiter=',')
error:
IOError: [Err... 阅读全帖 |
|
s**a 发帖数: 8648 | 12 CALL FOR GRADUATE STUDENT PAPERS: NORTHWESTERN TAX CONFERENCE, May 3-5, 2007
, Northwestern University
Taxation is a central social institution of the modern world. Taxes define
durable structures of inequality, delimit the capacities of the state, and
affect social behaviors from marriage to philanthropic giving. Conflict over
taxation has been a driving force in major historical and social changes
from the French Revolution to the democratic transitions of the late
twentieth century. In the co |
|
p********a 发帖数: 5352 | 13 【 以下文字转载自 JobHunting 讨论区 】
发信人: wuyiwuxi (无依无系), 信区: JobHunting
标 题: 一个很全SAS Interview Q. List [ZT]
发信站: Unknown Space - 未名空间 (Mon Jan 24 17:32:27 2005) WWW-POST
SAS Interview Questions from http://www.sconsig.com/
Very Basic
What SAS statements would you code to read an external raw data file to a DATA
step?
How do you read in the variables that you need?
Are you familiar with special input delimiters? How are they used?
If reading a variable length file with fixed input, how would you prevent |
|
A*********u 发帖数: 8976 | 14 1, !! is to concatenate character variables
"a"!!"b"="ab"
lenght of City_Country should be
length of First + lenght of " ," (1) + length of "England"
length 是在 compile 的时候决定的,compile的时候Function不执行
2, default length of the scan function result is 200
3, 原题的delimiter可能是', '即逗号和空格,你仔细看看
1,
data test;
first='Ipswich, England';
City_Country= Substr(First, 1,7)!! ','!!'England';
run;
请问这个!!(两个感叹号)是什么意思啊,是空格吗?好像在online tutor中没见过。
还有为什么length of city_country 是25?为什么不是17呢?
substr出来的值有default长度的吗?
2,
dat |
|
|
p********a 发帖数: 5352 | 16 需要COPY & PASTE至少5行数据吧,这不是一个通用的MACRO能解决的。
我以前发的那个MACRO,是自动读CSV格式的TEXT FILES的
读TEXT FILES,需要知道DELIMITER是什么,MISSING VALUES是什么,字段名是什么,
所以没有DATA不行啊 |
|
F*******1 发帖数: 75 | 17 Site1 - Site1000 are character variables. If I put Site1-Site1000 $ in the
INPUT statement as shown below, only Site1000 is showing as character
variable. Can somebody help me this? Thanks a lot!
data WindSummary;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile myfile delimiter = ',' MISSOVER DSD lrecl=102590 firstobs=2;
format DataItem $60. ;
INPUT DataItem $ Site1-Site1000 $;
run; |
|
F*******1 发帖数: 75 | 18 请教一个SAS 数据读入的问题. 我有个样本文件. 见附件.
我只需要第6行到第11行的数据. 在data statement 中, 我可以用firstobs=6 来定位
起事行. 那用什么来定位末位行呢? 我试了lastobs=11 不work. 谢谢!
如果我先读入所有数据,再提取需要的数据.我的sas script 如下. 但结果不对, 第7行
到第11行的数据丢了. 是什么原因呢? 谢谢!
data RT1;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile "\\mkscsas01\saswork\20090108_asm_rtmcp_final.csv" delimiter =
',' MISSOVER DSD lrecl=55010 firstobs=6 ;
format Pnode $12. MCPType $12.;
INPUT Pnode $ Zone $ MCPType $ HE1 - HE24;
run; |
|
o****o 发帖数: 8077 | 19 try the following code. At least on my PC, given the data structure, it
works on the data sets downloaded from the website
the point is to use Text Pointer in Data step;
/* take final.csv as one of the csv file on the website*/
filename final "c:\final.csv";
data test;
infile final delimiter=',' truncover dsd;
input @"MISO Wide,-," type :$10. HE1-HE23;
if ^missing(type) then output;
run; |
|
g*******t 发帖数: 124 | 20 sorry, a lot of questions...
The following SAS program is submitted:
data work.test;
Title = 'A Tale of Two Cities, Charles J. Dickens';
Word = scan(title,3,' ,');
run;
Which one of the following is the value of the variable WORD in the output d
ata set?
A. T
B. of
C. Dickens
D. ' ' (missing character value)
=>B
I ran in SAS, and it is B. The delimiter is ' ,', a space plus a comma.any t
rick of that?
thanks!! |
|
D*D 发帖数: 236 | 21 This means both space and comma are treated as delimiters
therefore the 3rd word is 'of' the 6th word is 'Charles'
d
t |
|
d*******1 发帖数: 175 | 22 I have a data file which is in a txt format,which includes a lot of columns
and is delimited by "|". I only want to pull a few of fields from data files
into SAS dataset.
How could I do that?
Any help would be appreicated. |
|
D******n 发帖数: 2836 | 23 如果一个field里面有逗号数据本来就应该输出成tab delimited,否则怎么读啊?
可以试试@ 这个东东 |
|
x**m 发帖数: 941 | 24 How about you read the data in your way using "," delimiter, and then you
put city and state together into LOCATION later, if it is necessary. |
|
P****D 发帖数: 11146 | 25 没看懂。你的问题不是已经解决了?既然已经知道“发现这两个格式都不能导入HLM,
除非SPSS数据转化成sav后缀名的格式,或者SAS转化成sas transport后缀名的格式。
”,那就照做就是了啊。
如果你是手里只有.sps(SPSS没有这种后缀名,你看错了sys?)和.sas7bdat(SAS后
缀名)文件但不知道怎么转化的话。我假设你手里有SPSS和SAS软件。那么双击打开.
sas7bdat,然后File->Export Data->Next->有个下拉框可以选你要的格式,可以选
Excel或Tab Delimited File(我就不信有软件不支持这两种格式)-> Next->告诉SAS
你想把转换成的文件存放在哪里->确定,然后看到“完成”出来的时候就点完成。 |
|
a***r 发帖数: 420 | 26 这个方法很笨,其实应该在第一步读入原始文件的时候就可以设的两种delimiter的吧
,但我现在不会。。。 |
|
j***3 发帖数: 142 | 27 I got the half matrix as txt (tab delimit) or csv format file from upstream
analysis. |
|
E********9 发帖数: 7 | 28 请教大家一个问题:
I'd like to import several .csv file to SAS, but how come I can't use
statement like
MIXED=YES;
USEDATE=YES;
SCANTIME=YES;
in the proc import procedure?
Here is my code:
proc import datafile="---.csv" out=sasuser.trial dbms=csv replace;
delimiter=",";
getnames=yes;
MIXED=YES;
USEDATE=YES;
SCANTIME=YES;
run;
I'm working on UNIX, so didn't try converting csv files to excel before
importing them. Without the statements mentioned above, I have a lot of
error mes |
|
E********9 发帖数: 7 | 29 Thank you for your reply.
Below is the log I got:
proc import datafile="---.csv" out=sasuser.trial dbms=csv replace;
NOTE: The previous statement has been deleted.
NOTE: The previous statement has been deleted.
3 delimiter=",";
4 getnames=yes;
5 MIXED=YES;
-----
180
6 USEDATE=YES;
-------
180
7 SCANTIME=YES;
--------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
8 run;
I |
|
M*********9 发帖数: 15637 | 30 是按一个数据读的。 怎么INDEX, SUBSTR一个一个弄? 因为今后数据可能会很大,
EXCEL每次只能DELIMIT一个COLUMN。 俺在想是不是有什么方法让SAS给搞定。 不然要
使几百COLUMN,岂不要了俺的小命。
多谢。 俺自己也在乱试多COLUMN的情况。 |
|
D******n 发帖数: 2836 | 31 who said that?
u can do this task in excel,
paste the data in excel, and use import data with wizard...choose space and
/ as delimiter...done. |
|
s*******f 发帖数: 148 | 32 i'm trying to scan &syspbuff in order to assign the value to a macro
variable call &cc.
Usually i do it like this:
%macro m1 / parmbuff;
...
%let cc=%scan(&syspbuff,2);
...
%mend m1;
%m1(a,b,c,d,e)
Here &cc will be resolved to b.
But what if i would like to scan some strings with single quotes and commas?
such as:
%m1(%str('a','b','c')*%str('d','e'))
Here * is the delimiter (and i dunno if i treat it right with %str). I wanna
get the 'd','e' part as a whole from the scanning above.
I |
|
j**********e 发帖数: 442 | 33 您真是太谦虚了。这样确实就可以work了。给您发了20个伪币,聊表寸心。
有个问题是:根据上面的代码,在company和000007之间只能有:而不能有任何空格。有没有办法允许在:后有空格呢?
我才搞清楚,原来是中文的问题。中文一个字占两格,所以在读取冒号后面的值时有困难(到底为啥困难我也不明白)。我把冒号删除了然后在英文输入法环境下再添上冒号就可以了。但是文件太多,一个一个这样弄太费时间。大家有好办法吗?
附上整个宏(测试用,所以num只从0到1):
%macro input_file;
%do num=0 %to 1;
data file_sub;
infile "C:\research\A (&num).txt"
firstobs=1
delimiter=":" truncover;
input col_1 $20. ;
n=_N_;
if n=1 then company=scan(col_1,2,':');
retain company;
if n=4 then date=in |
|
s******y 发帖数: 352 | 34 that is so called brotherhood, right.
well, I thin you asked how to add quotation mark to each word in the
sentence. the QUOTE function merely add one at begining and one at the very
end.
so for this task, I would like to use Regex. it is one liner solution. but
certainly, you can loop through and add the quotation mark for each word
delimited by space.
any way here is the code:
data _null_;
infile cards truncover;
length quoted_line $600.;
input line $200.;
quoted_line=prxchange('s/([\w''""]+)( |
|
g**a 发帖数: 2129 | 35 the format of cityname has to be defined before using scan function. e.g. No
space for city name, or special delimiter for the whole city name |
|
f*****a 发帖数: 693 | 36 Try this one. Can some one give some improvement, such as change variable
file into a file which includes all the to be input file names? Thanks.
%macro openfile(file);
%let file=all you file name list with space as delimiter (no space inside
file names);
%let i=1;
%let name=%scan(&file,&i);
%do %until(not %length(&name));
proc import out=work.&name
datafile="h:\&name"
dbms=excel replace;
sheet="sheet1";
getnames=yes;
mixed=no;
scantext |
|
p********2 发帖数: 9939 | 37 我想把一个character variable里面的所有空格,逗号,括号都去掉,该用什么
function呢?谢谢。
再则,我要去掉一个一个特定的substring,又该怎么办呢。谢谢。 |
|
S******y 发帖数: 1123 | 38 #Python 2.5
import re, string
regex = re.compile('[%s]' % re.escape(string.punctuation))
def remove_puctuations_re(s): #remove puctuations
return regex.sub('', s)
============================================= |
|
p********2 发帖数: 9939 | 39 我找到一个compress function可以去掉单个character,有没有去掉一个string的? |
|
|
p********2 发帖数: 9939 | 41 谢谢。我另外一个问题.比如我想去掉一个独立的substring,比如结尾是空格+CO,
which is what I want to remove。但是CO也存在别的substring里面,比如
communication。我要是去掉CO,就把communication里面的co也去掉了,这可如何是好。 |
|
S******y 发帖数: 1123 | 42 #use Python regular expression
>>> s='abc CO'
>>> re.sub(r"\bCO$","",s)
'abc '
========================= |
|
|
R*********i 发帖数: 7643 | 44 Still tranwrd. Use ' CO': tranwrd(yourvariable,' CO','');
好。 |
|
a*****3 发帖数: 601 | 45 还有其他字符呢?like comma, left parenthesis, etc. |
|
R*********i 发帖数: 7643 | 46 Did lz say "space+CO" at the end?
In case there are "space+CO" in the middle of the string, try
if substr(reverse(upcase(a)),1,3)='OC ' then a=substr(a,1,length(a)-4); |
|
p********2 发帖数: 9939 | 47 en解决了,我在末尾加了个空格,‘ ’, 然后去掉‘ CO '. 这样中间的’ CO ' 和
末尾的‘ CO ' 都能去掉. 而又不会去掉一个word里面含有的CO |
|
on 发帖数: 199 | 48 because sometimes other files use this type of nonprintable stuff, say, from
dos file, cms file; or sometimes files use them as delimiters. I need to
remove them before I can see files in an organized way.
nonprintable |
|
a*****3 发帖数: 601 | 49 lz要的是阿斯卡码表吗?
http://blog.henghome.com/archives/200
from: dos file, cms file; or sometimes files use them as delimiters. I need
to: remove them before I can see files in an organized way. |
|
f******9 发帖数: 267 | 50
There are not any field delimiters. How to let R treat them individually
instead of string? |
|