<div dir="ltr">Hi Dale,<br><br>I do not how your file looks like, so created a dummy file without any header lines (attached).<br><div>Following two methods should work for what you want:</div><div><br></div><div>mehtod1:</div><div><br></div><div> nrow   = 10<br> ncol    = 25<br></div><div></div><div> infile1 = "dummy_file.csv"<br> lines1  = asciiread (infile1, -1, "string")<br> delim   = ","<br> data    = new((/nrow,ncol/),float)<br> do n=0,ncol-1<br>    tmp       = tofloat(str_get_field(lines1,2+n,delim)) ; .......... note str_get_field starts at 1, NOT 0<br>    data(:,n) = tmp(0:nrow-1)<br> end do<br> print(data(:,0)+","+data(:,1)+","+data(:,2))<br><br></div><div><br></div><div>method2 (suggested by Mary):</div><div><br></div><div> nrow   = 10<br> ncol    = 25</div><div><br></div><div> infile1 = "dummy_file.csv"<br> lines1  = asciiread (infile1, -1, "string")<br> delim   = ","<br> csv_lines = str_split_csv(lines1,delim,0)<br> data      = csv_lines(0:nrow-1,1:ncol-1)<br> print(data(:,0)+","+data(:,1)+","+data(:,2))<br></div><div><br></div><div><br></div><div>Hope that helps, and let me know if you have further questions regarding this.<br></div><div><br></div><div>Rashed<br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 7, 2018 at 7:28 PM, dale zuri via ncl-talk <span dir="ltr"><<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div dir="auto">Hi , </div></div><div dir="auto">Thanks.  I would like to extract specific row by specific column.   </div><div dir="auto">For example, leaving the date column extracting the first 10 rows and 25 columns. </div><div dir="auto">I couldn't leave the date column. Could someone help me to figure it out? </div><div dir="auto"><br></div><div dir="auto">Dz</div><div dir="auto"><br></div><div><br><div class="gmail_quote"><div>On Tue, Nov 28, 2017 at 7:44 AM Mary Haley <<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-size:small">Hi,</div><div style="font-size:small"><br></div><div style="font-size:small">For CSV data, I recommend using str_split_csv to extract the data:</div><div style="font-size:small"><br></div><div></div></div><div><div><div><font face="monospace, monospace">infile1 = "AK_BackCast_StnData-Temp.csv"</font></div><div><font face="monospace, monospace">lines1  = asciiread (infile1, -1, "string")</font></div></div></div><div><div><div><font face="monospace, monospace">delim = ","</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">;months starts in column #0</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">csv_lines = str_split_csv(lines1(2:),<wbr>delim,0)</font></div><div><font face="monospace, monospace">date      = csv_lines(:,0)          ; first column</font></div><div><font face="monospace, monospace">col2      = toint(csv_lines(:,1))   ; second column </font></div><div><font face="monospace, monospace">col3      = toint(csv_lines(:,2))   ; third column </font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">print(col3)    ; use "tofloat" in place of "toint" if you want floating point data</font></div><div style="font-size:small"><br></div><div style="font-size:small">--Mary</div><div style="font-size:small"><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"></div></div><div class="gmail_extra"><div class="gmail_quote">On Mon, Nov 27, 2017 at 4:25 PM, dale zuri <span><<a href="mailto:dalezuri@gmail.com" target="_blank">dalezuri@gmail.com</a>></span> wrote:<br></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div><div><div><div><div>Hi ,<br></div>I have an issue with reading the CSV. <br><br></div>I would appreciate any help and suggestions. <br><br></div>Thanks<br>begin<br><br><br>infile1 = "AK_BackCast_StnData-Temp.csv"<br>lines1  = asciiread (infile1, -1, "string")<br>print(lines1)<br>delim = ","<br>;months starts in field number 1<br>name  =  str_get_field(lines1,3,delim)<br>print(name)<br><br></div>I want to read each column with associated string field. <br></div>Except number 1 and 2, the rest of the field numbers are not correct. For example, number 3 field, print the different column. <br><br></div>I don't understand whats happening here. <br><br><br></div>
<br></blockquote></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div></div>
<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div></div>