Reading columns?
How can I use the read out loud function to read down columns in a pdf, when it is now reading across columns?
This code won't compile and is not the best way but should give you and idea. You'll need to add some try-catch blocks.
Use BufferedReader.readLine() to grab each line of text.
Use StringTokenizer to break up each line. In your case the delimiter will be a comma.
Should look something like this:
BufferedReader in = new BufferedReader(new FileReader("yourFileName"));
StringBuilder sb = new StringBuilder();
StringTokenizer st;
while ((sb = in.readLine() ) != null)
st = new StringTokenizer(sb.toString, ",");
st.nextToken() -> your chars
st.nextToken() ->your date
st.nextToken() -> your double
etc...
}
Similar Messages
-
Reading column data type in SSAS tabular database using adomd
I am working on SSAS tabular database and I need to find out the column datatype. I am using ADOMD for this. So far I looked at AdomdDataReader.GetSchemaTable
Method & looked at the below code snippet to retrive Metadata from the AdomdDataReader.
foreach (DataRow objRow in schemaTable.Rows)
foreach (DataColumn objColumn in schemaTable.Columns)
Console.WriteLine(objColumn.ColumnName + " = " + objRow[objColumn]);
Console.WriteLine();
I wonder with only the list of columns available to me, how can I execute a query/command and utilize adomd reader to get this information?
What is the best approach to read column metadata?Hi, One option that you can try is to use AMO. Here is a sample code that connects to multi-dimensional model.
http://sqlblogcasts.com/blogs/drjohn/archive/2012/03/15/ssas-utility-to-check-you-have-the-correct-data-types-and-sizes-in-your-cube-definition.aspx
You will have to change few things to make it work for tabular model. Sorry, I did not try myself but I hope this will give you some ideas.
// get DSV - this code assumes only one DSV in cube definition
AMO.DataSourceView
dsv = olapDatabase.DataSourceViews[0];
foreach (AMO.Dimension
dim in olapDatabase.Dimensions)
foreach (AMO.DimensionAttribute
attr in dim.Attributes)
foreach (AMO.DataItem
dItem in attr.KeyColumns)
AddAttributeDataItem(dtCubeDataTypes,
"Key", dsv, attr, dItem);
AMO.DataItem contains column size and data type when connected to a tabular database. -
Datawarehouse Admin Console : Reading column failed
While importing column from Database (MSSQL) into Datawarehouse Admin Console i am getting below error.
Reading Columns failed
com.siebel.analytics.etl.schema.reader.SchemaReaderException: Error while initializing the list of tables.
Help me to resolve the issue.
Thanks
LakshmiBest try another forum for the BIApps DAC questions
Cheers
David -
Vc++ how to read column header of cursor
How to fetch the Column name or header of the stored procedure which is using a cursor as the output.
P_out out sys_refcursor
need to read the column name of this output.
I am using Vc++ code to reterive the data, in Vc++ how to read column header of cursorYou haven't provided much detail to go on. How are you reading data from the ref cursor? Do you already have a reader from it?
Maybe this helps.
Greg
create or replace procedure proc1 (v1 out sys_refcursor) as
begin
open v1 for select * from emp;
end;
using System;
using System.Data;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
public class RefCur
public static void Main()
using (OracleConnection con = new OracleConnection("user id=scott;password=tiger;data source=orcl"))
con.Open();
using (OracleCommand cmd = new OracleCommand("proc1", con))
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new OracleParameter("v1", OracleDbType.RefCursor, ParameterDirection.Output));
cmd.ExecuteNonQuery();
using (OracleDataReader reader = ((OracleRefCursor)cmd.Parameters[0].Value).GetDataReader())
for (int i=0;i<reader.FieldCount;i++)
Console.WriteLine(reader.GetName(i)); -
Setting Reader Column Width?
Anyone have any idea how Reader determines the column width it displays? For my blogs, it cuts off all my photos, because they're wider than Readers default column width.
Look, for example at this page:
http://www.ultrasomething.com/photography/2010/03/that-golden-glow/
If you click the READER button, every photo has its right side chopped off by Reader viewer.
Anyone know if this is something fixable (short of recoding all my articles to fit Reader's column width)?
Thanks.
-egorHI,
I see what you mean.
Not sure if that is "fixable" or not but go to the Safari Menu Bar and click Safari/Report Bugs to Apple.
Reporting bugs is a good way to get glitches fixed.
Carolyn -
Writing colums and reading columns
when i am writing values in the controls (VI attached).in the column headers i write deliberately
CYCLES header after giving space after TIME header.this is because when i see the corresponding text file in notepad.the headers looks fine but in the Table CYCLE header look moved to other column.in
the wordpad all headers looked moved. why it is like this? why cannot same time in table, notepad and wordpad i dont see the header on its appropriate column.
The other issue is when i am reading the same text file that i already wrote.i am getting zeros in first row,first column and last column. i am just deleting the first row and first column.i am also deleting the last column zeros. but i am not sure whether this meth
od of just deleting zeros is correct or wrong.whether i am deleting some important data or not?(VI attached).
Thanks for your help
Attachments:
save_values.vi 143 KB
readfilemaketable.vi 32 KBYou won't ever get the same look in notepad or wordpad that you would see in a table. The table automatically lines up the data in rows and columns. In notepad or wordpad, all it sees is data, space, data, space, etc. There is no mechanism to line up into columns. You could force the line up if you inserted a tab character between each data value. then you would have data, tab, data, tab,... Notepad would see the tab and move to the next tab mark, thereby lining up the columns. However, if one of the data fields or headers have more characters than the next tab mark, a misalignment could take place. If you want to see things lined up, use a spreadsheet instead of notepad.
On your second issue, the first column (column 0) and first row (row 0) are he
ader information, like "Block 1" and "Amplitude". When reading the file, these values cannot be converted to a number, so you will see a 0 in all columns of the first row and all rows of the first column. When you delete the first row and first column, you are eliminating the headers and get the correct data. Column 6 has zeros because there is no data in column 6. There is a column 6 becasue you wrote the file with a space before CYCLE. This created a column header with no data in that column. Your data for Cycle fell under the column with a space for a header. You do not need that space before CYCLE. Take it out. (Don't worry about it not lining up in a text file, it won't) Then you won't need to delete column 6 because there won't be any column 6. After deleting column 0 (Block#), you will be left with columns 1 through 6 shifting to occupy columns 0 through 5 to fill in for the deleted column.
- tbob
Inventor of the WORM Global -
SQL Server JDBC Must read columns in order?
Is this some kind of sick joke?
If I use rs.getString() to retrieve columns by name from the data base, they must be retrieved exactly in the order that they appear in the actual database, or else an error will result.
Someone please tell me that this is not the case.Some JDBC drivers make that restriction. Apparently the JDBC specification allows them to do so. So, it's possible that the SQL Server driver does that, and your post implies that it does.
-
How to read columns from spreadsheet?
I have text based spreadsheet files containing several columns of data (previously collected data written to file by "write to spreadsheet file" function). Each column is separated by a tab character.
I need to plot each column on a separate waveform chart. I am trying to use the "read data from spreadsheet" function to do this, which I understand reads in the spreadsheet file as a 2D array.
I cannot figure out how to separate each column from the 2D array which is the output of the "read data from spreadsheet" function. For each column in the spreadsheet, I need a 2D array, the first row of which is a series of numbers (1, 2, 3, 4, 5, 6 etc) representing arbitrary time points, and the second row is the act
ual data from ONE column of the spreadsheet. I could then wire this 2D array to a waveform chart. I would need a separate 2D array for each column in the spreadsheet.
Could someone suggest how this can be done? Better yet, is there example code available somewhere that shows how to do it?
Thanks.Array indexing in LabVIEW version 6i can be confusing.
I include an example code that you can study to see how it is done in your case.
Basically, you need to disable the row index when using the ArrayIndex function. In earlier versions of LabVIEW this was done by right clicking on the index-input and selecting disable/enable input but with the new version this is no longer needed. Just wire what you have and the other port will be disabled automatically. However, if you are using version 6i, make sure you wire the array to the ArrayIndex first. You should then get a 2D version of the Indexing function automatically. In older versions you had to manually drag it to a bigger dimension. Attached are two files. One data file, data.txt, with three rows and three co
lumns, and one VI, ColumnIndexing.vi, that reads out a specific column from that text file.
This example code is compatible with LabVIEW 4.1 and up.
Hope this helps. /Mikael
Attachments:
data.txt 1 KB
columnindexing.vi 21 KB -
hi!
I add a colunm in a matrix, with type it_EDIT
SboColumn = sboMatrix.Columns.Add(Key, SAPbouiCOM.BoFormItemTypes.it_EDIT)
The user type a char in the column. Then I want to read tha value:
sboEditTextKey = sboMatrix.Columns(Key).Cells.Item(Row).Specific
with this line code, sBO crash
str_Value = sboEditTextKey.Value
I must use this:
str_Value = sboEditTextKey.string
versione BO:6.50.097 SP:01 EF:03Andrea,
the value you are trying to read is stored inside a control SAP calls EditText (basically a textbox).
The EditText has no value property, hence the crash.
It is better (and recommended by SAP) to cast the item.specific into the control it really is.
sboMatrix.Columns(Key).Cells.Item(Row).Specific.string
will work, but it involves late binding.
See below:
Dim sboEditTextKey as EditText
sboEditTextKey = sboMatrix.Columns(Key).Cells.Item(Row).Specific
str_Value =sboEditTextKey.String
Nothing wrong with SAP here. Exept for causing a total crash, which is a little over the edge
HTH Lutz Morrien -
Import data from txt-file with reading column names
Hello,
after changing the the export of my simulation programm I can't use the solution postet here, wich works well. (I branded the post as soluted thats why I start a ne post)
Can anybode please tell me how to adept the code to import the new type of txt file. Here the name of the columns are in the first line aof the columns, like this (with ignoring the first lines).
"TIME " "Sitzbasis_X" "Sitzbasis_Y" "Sitzbasis_Z" "Achsklammer_Z" "Antriebsachse_Z" "Gegengewicht_Z" "Lenkachse_Z"
0.000000e+000 -5.472285e+003 -1.886681e+002 1.812099e+004 4.539113e+004 -1.252936e+005 -1.499764e+004 -9.806650e+003
1.000000e-003 -1.722846e+003 -1.141275e+002 8.443419e+003 2.475389e+004 -7.533712e+004 -1.138092e+004 -9.624729e+003
2.000000e-003 -3.964053e+002 -7.694600e+001 3.186345e+003 1.399086e+004 -5.653730e+004 -9.956198e+003 -9.311346e+003
I added an example file
Thanks for Help
Gabriel
Solved!
Go to Solution.
Attachments:
TXT-File.txt 115 KBHello Gabriel
You can use the DataPlugin Wizard (Navigator>>File>>DataPlugin Wizard) to define a new file import filter for your data. It will take only one minute.
Please found the uri file I create for you. Copy the attached file to your disk, unpack it and double click the uri file.
Then you can open your file by using "open with".
Hope this help
Attachments:
TXT_File_DataPlugin.zip 4 KB -
Reading columns with '#' in name
I want to read some Oracle specific info using:
@Entity
@NamedNativeQuery(
name="sessionInfo",
query="SELECT sid, serial# AS session_serial FROM V$SESSION WHERE audsid = sys_context('userenv', 'sessionid')",
And get following exception:
Exception Description: Query argument not found in list of parameters provided during query execution.
Problem is, that character # is recongized as parameter prefix. Is any workaround for this ?
Thankssomething like
select t1.table_name
, t1.column_name
, t1.data_type
, t1.data_length
, t2.table_name
, t2.column_name
, t2.data_type
, t2.data_length
from user_tab_columns t1
, user_tab_columns t2
where t1.table_name != t2.table_name
and t1.column_name = t2.column_name
and t1.data_type = t2.data_type
and t1.data_length != t2.data_length... could be a starting point. -
How to read columns of a Microsoft Excel .csv file with LabVIEW?
This should be simple. Any ideas on how to read an Excel file with csv extension using LabVIEW?
Thanks!Use the Read From SpeadSheet File.VI which you can find on the FILE I/O pallette.
"Read From Spreadsheet File
Reads a specified number of lines
or rows from a numeric text file beginning at a specified character offset and
converts the data to a 2D, single-precision array of numbers. You optionally can transpose the
array. The VI opens the file before reading from it and closes it afterwards.
You can use this VI to read a spreadsheet file saved in text format. This VI
calls the Spreadsheet String
to Array function to convert the data."
The CSV file is essentially a text file which uses commas as delimiters in the files structure. -
Reading columns after a "fetch_rows" command
Dear All:
Could somebody help me with this issue?
The following is a sample code to declare, open and fetch a Dynamic Cursor using BIND_ARRAY command ...
declare
c number;
d number;
n_tab dbms_sql.Number_Table;
indx number := -10;
begin
c := dbms_sql.open_cursor;
dbms_sql.parse(c, 'select cod from emp order by 1', dbms_sql);
dbms_sql.define_array(c, 1, n_tab, 10, indx);
d := dbms_sql.execute(c);
loop
d := dbms_sql.fetch_rows(c);
/* The problem is here ...... */
/* After to read the first row, I can not identify a way to read the following row fetched, how can I read the first 10 rows fetched and stored in n_tab variable? */
dbms_sql.column_value(c, 1, n_tab);
exit when d != 10;
end loop;
dbms_sql.close_cursor(c);
exception when others then
if dbms_sql.is_open(c) then
dbms_sql.close_cursor(c);
end if;
raise;
end;
The problem is that I can not identify a way to read each row fetched in n_tab after the fetch_rows command, It's supposed that n_tab store 10 rows each time, but how can I read these 10 rows? Is it enough with the column_value command? after this Do I have to reference each row by n_tab[1], n_tab[2] .... n_tab[10] to read the codes fetched?
Thank you to everybody for your attention
Regards
JosiDear All:
Could somebody help me with this issue?
The following is a sample code to declare, open and fetch a Dynamic Cursor using BIND_ARRAY command ...
declare
c number;
d number;
n_tab dbms_sql.Number_Table;
indx number := -10;
begin
c := dbms_sql.open_cursor;
dbms_sql.parse(c, 'select cod from emp order by 1', dbms_sql);
dbms_sql.define_array(c, 1, n_tab, 10, indx);
d := dbms_sql.execute(c);
loop
d := dbms_sql.fetch_rows(c);
/* The problem is here ...... */
/* After to read the first row, I can not identify a way to read the following row fetched, how can I read the first 10 rows fetched and stored in n_tab variable? */
dbms_sql.column_value(c, 1, n_tab);
exit when d != 10;
end loop;
dbms_sql.close_cursor(c);
exception when others then
if dbms_sql.is_open(c) then
dbms_sql.close_cursor(c);
end if;
raise;
end;
The problem is that I can not identify a way to read each row fetched in n_tab after the fetch_rows command, It's supposed that n_tab store 10 rows each time, but how can I read these 10 rows? Is it enough with the column_value command? after this Do I have to reference each row by n_tab[1], n_tab[2] .... n_tab[10] to read the codes fetched?
Thank you to everybody for your attention
Regards
Josi -
Hello,
Can anyone help me out to write a vb.net script.
I need to read the column names from excel and based on that column names I need to create a table in database(I have more than one sheet in excel).
For each sheet columns will be changing and should create a table dynamically for each sheet.
Any help would be appreciated.Refer the below script to read columns in each sheet.
Dim excelfile As String = Dts.Variables("ExcelPath").Value.ToString
Dim connectionstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + excelfile + ";Extended Properties=Excel 8.0"
Dim oledbcon As New OleDb.OleDbConnection(connectionstring)
oledbcon.Open()
Dim dt As DataTable
Dim schemaTable As DataTable
Dim OLEDBCMD As New OleDb.OleDbCommand
Dim oledbdatareader As OleDb.OleDbDataReader
Dim columns As String = ""
dt = oledbcon.GetSchema("Tables")
Dim TABCOMMAND(20) As String
Dim TABCOUNT As Integer = 0
For Each row As DataRow In dt.Rows
TABCOMMAND(TABCOUNT) = "SELECT * FROM [" & row.Item("TABLE_NAME").ToString & "]"
OLEDBCMD.CommandText = TABCOMMAND(TABCOUNT)
OLEDBCMD.Connection = oledbcon
oledbdatareader = OLEDBCMD.ExecuteReader(CommandBehavior.KeyInfo)
schemaTable = oledbdatareader.GetSchemaTable()
For Each myfield As DataRow In schemaTable.Rows
For Each myproperty As DataColumn In schemaTable.Columns
If myproperty.ColumnName = "ColumnName" Then
columns = columns & myfield(myproperty).ToString & ","
MsgBox(myfield(myproperty).ToString)
End If
Next
Next
oledbdatareader.Close()
OLEDBCMD.Dispose()
Next
oledbcon.Close()
Regards, RSingh -
How to read excel file in document library and store excel content in sql table
Hello,
Can anyone help me how to read the excel file present in document library and store the content inside excel into sql table?
Please let me know the ways to acheive this. Feel free to give your suggestions.
Thanks,
Cool DeveloperHi!
this code i have written becuase i donot find any soltions on net for this , u can try with this . :)
System.Data.OleDb.
OleDbConnection ExcelConnection = null;
FileMode fileMode;
string filePath = ConfigurationManager.AppSettings["TempLoaction"] + "\\" + fileName;
using (SPSite _site = new SPSite(SPContext.Current.Web.Url))
using (SPWeb _web = _site.OpenWeb())
string docLibrary = ConfigurationManager.AppSettings["DocumentLibrary"];
SPFile _file = _web.GetFile("/" + docLibrary + "/" + fileName);
fileMode =
FileMode.Create;
byte[] byteArray = _file.OpenBinary();
MemoryStream dataStream = new MemoryStream(byteArray);
Stream stream = dataStream;
using (FileStream fs = File.Open(filePath, fileMode))
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) != 0)
fs.Write(buffer, 0, bytesRead);
fs.Close();
//Create the Connection String
try
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;
Data Source ='"
+ filePath + "'; Extended Properties=Excel 5.0";
//Create the connection
ExcelConnection =
new System.Data.OleDb.OleDbConnection(ConnectionString);
//create a string for the query
string ExcelQuery;
//Sheet1 is the sheet name
//create the query:
//read columns from the Excel file
ExcelQuery =
"Select * from [Sheet1$]"; // from Sheet1";
//use "Select * ... " to select the entire sheet
//create the command
System.Data.OleDb.
OleDbCommand ExcelCommand = new System.Data.OleDb.OleDbCommand(ExcelQuery, ExcelConnection);
//Open the connection
ExcelConnection.Open();
//Create a reader
System.Data.OleDb.
OleDbDataReader ExcelReader;
ExcelReader = ExcelCommand.ExecuteReader();
//For each row after the first
while (ExcelReader.Read())
thanks,
kshitij
Maybe you are looking for
-
Does anybody know, what algorithm use lightroom when resize during export? I tried to compare resize by lightroom and photoshop (bicubic and bilinear) and I must say the best result for my eyes is bilinear resize used by image processor in PS.
-
I created both xa datasource and non-xa datasource in jonas server .assumed that them xads and nxads. and then , i want to get a non-xa connection from nxads in a global transaction context. but when i commit it, the exception "jonas could not use lo
-
I just purchased the 70D and want to connect it with my Macbook for easy file sharing, but my laptop does not have a CD-ROM drive. I downloaded the utility off the website, but it won't allow me to run it without the CD-ROM that came with the camera.
-
Apps Taking Up Significantly More Space Than The Size of the App
I'm having an issue where the meter for my iPad registers a significantly higher hard drive usage to "Apps" than the apps file size in the list. It's showing 5.4 GB, when the total size of the apps installed is 240 MB. I do have VLC and two videos sy
-
Printer service on a Mac Mini server?
Hello! I have a new Mac Mini server (mid 2010). I have a USB printer connected to it. I have no problem printing locally. However, I can't seem to figure out how to print from a client machine. I don't see the printer in the "add printer" from the pr