Resultset to ascii file
Hi,
Is there an easy way in oracle 9i to write the resultset of a query to an ascii file ?
Regards,
Ned
Since you already have a query that outputs in the XML format that you want, you could just write a SQL script that spools the results of your query to a file, then schedule the execution of that script as a CRON job. That would probably be the easiest way to do it. Alternatively, you could write a PL/SQL procedure that uses UTL_FILE to write the results of your query to a file, then schedule that procedure using DBMS_JOB.SUBMIT. Here is an example of the first method, that will spool the results to a file name containing today's date, for example aug-06-2003.xml. It will also save your original set commands and restore them after the spooling.
STORE SET saved_settings REPLACE
SET ECHO OFF FEEDBACK OFF HEADING OFF PAGES 0 VERIFY OFF
COLUMN dt NEW_VALUE today
SELECT TO_CHAR (SYSDATE, 'mon-dd-yyyy') dt FROM DUAL;
SPOOL &today..xml
-- put your query here
SPOOL OFF
START saved_settings
Similar Messages
-
How can I extract a dates column from an ascii file
I am extracting data from an ascii file and the rest of the data is extracted using read from spreadsheet, but the date appears as just the day e.g. 22 for 22nd, how can I get the date, format in ascii is e.g 22/04/2006, can I do this by specifying something at format of read from spreadsheet ? Cheers
EmilyHi,
I found the other day that there are instructions included inside the Read From Spreadsheet vi on how to modify it slightly to read strings rather than doubles.
If you drop the Read From Spreadsheet vi onto the block diagram and double click on it, you will open the front panel for the vi. If you then select the block diagram (for Read From Spreadsheet) you will see an 'instructions' frame below the main 'code', and the 3rd paragraph tells you how to modify the VI to read the spreadsheet as a set of strings rather then doubles. Save the vi as a new filename when you've edited it or you will overwrite the existing vi!
Using the newly modified vi you can read in your entire spreadsheet, extract the dates as strings, then do any conversion necessary to the other columns of the sheet to change them into the types of value you require (eg doubles).
I hope this helps.
Mark
Applications Engineer
National Instruments -
Deleting rows from a table matching values from an ascii file
Hi All,
I have an ASCII file with 12,000 lines. Each line represents a value (you may call this as bad data) that matches a database column value in table. I have to delete all the rows from a database table (~ 400,000 rows) where a column value matches the bad data value. Linux is the OS is where SQLPLUS client is installed and I can execure any SQL queries from this Linux server. Oracle DB server is 10g.
Any input on how to do this will be helpfull to me. I am not a database programmer so if any details will be appreciated.
ThanksHi,
That's going to be very slow (among other problems) if you don't have the bad data in a table. An index-organized table would probably be best.
Assuming the data data are uinique strings, up to 30 characters long, and that you don't need any other columns, you can create a table like this:
CREATE TABLE bad_data
( bad_txt VARCHAR (30)
, CONSTRAINT bad_data_pk PRIMARY KEY (bad_txt)
) ORGANIZATION INDEX;SQL*Loader is one way of getting the data from the file (doesn't have to be on the database server; it can be on your client machine) into the table.
Once you have a table, actually removing the rows from the big table might be as simple as:
DELETE big_table
WHERE column_a IN
( SELECT bad_txt
FROM bad_data
; -
Please help me in reading the ascii file in encoded format
hi ,
iam trying to read the ascii file and i need to encode the text file, can u suggest me what arre the different methods are availble for me to encode the text file, please suggest me which is the effiecient method tto use?This question has been answered before, please search the forums in future.
You could do something like this, it probably not the most efficient though.
If you don't need to do it in code then the native2ascii does this conversion see: http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/native2ascii.html
public static void convert(String vsFile) throws IOException
File f = new File(vsFile);
FileReader fr = new FileReader(f);
char[] buf;
int bytesRead = 0;
int startAt = 0;
String content = "";
do
buf = new char[512];
bytesRead = fr.read(buf, 0, 512);
startAt += bytesRead;
String tmp = new String(buf);
content += tmp;
while (bytesRead == 512);
FileOutputStream fout = new FileOutputStream(f);
OutputStreamWriter out = new OutputStreamWriter(fout, "UTF-8");
out.write(content.trim());
out.flush();
out.close();
} -
Problem with non-ASCII file name in content disposition header
Hi All,
I am facing some problems with the non-ASCII file name incase of content-disposition header. I read from the RFC 2183 that if the file name contains non-ASCII characters then the same should be encoded before sending to browser. I did the same but realized 2 problems:
1. The name of the file is truncated in case the file name is slightly long for e.g. �����������j�b�g��������������������������.txt
2. Also when the same file is opened in notepad, the title is showing encoded name %E6%9C%80%E4%B8%8A%E4%BD%8D.....
Overall, I feel that the browser is not understanding or responding to the encoded header values.
Is there any solution to this problem? I am using Microsoft IE 6.0.
The code snippet is given below:
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String fileName = "�����������j�b�g��������������������������.txt";
fileName = URLEncoder.encode(fileName, "UTF-8");
resp.setCharacterEncoding("UTF-8");
resp.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
resp.setContentType("application/download-binary");
String s = "This is inside txt file";
resp.getOutputStream().write(s.getBytes("UTF-8"));
return;
}Any help or pointer would be highly appreciated.
Thanks and Regards,
AshishThe MIME standards for non-ASCII filenames are not widely implemented.
Many mailers use an ad hoc method for encoding filenames. JavaMail
supports both methods, but you need to set properties, such as the
mail.mime.encodefilename property. See the JavaMail javadocs for
the javax.mail.internet package. -
How do i create a list of frequencies +/- a peak output as ascii file?
I have an VI set up that reads in from a Spectrum Analyzer and searches for the peaks and outputs them along with there amplitudes as an ASCII file.
A Macro has been created in Excel that reads the ASCII file and creates a list of 5 frequencies +/- the peak frequencies above a threshold to be tested later. The problem is that it has some frequencies
created more than once.
Is it possible to create this list in the VI that would filter the list and then output it to excel to be printed later?ChrisKalina wrote:
I have an VI set up that reads in from a Spectrum Analyzer and searches for the peaks and outputs them along with there amplitudes as an ASCII file.
A Macro has been created in Excel that reads the ASCII file and creates a list of 5 frequencies +/- the peak frequencies above a threshold to be tested later. The problem is that it has some frequencies
created more than once.
Is it possible to create this list in the VI that would filter the list and then output it to excel to be printed later?
Of course it is possible to do this. What have you tried so far?
One problem you will have, though, is that LV 5 is such an ancient version, many people on the forums will have trouble being able to open your file, and almost no one will have the means to save back that far. So you may have a hard time getting help. -
Can Signal Express prompt the user for the next ascii file name?
I am using the following to collect data from Thermocouples and Strain Guages in our plant. It allows me to plt data every second, while recording only every 3 seconds to cut down the file size.
Big Loop-
Small Loop-
Conitional repeat...
DAQmx Aquire...
Statistics (mean) Temp...
Statistics (mean) Press...
Current Iteration...
End Small Loop-
Save to ASCII/LVM
The problem is that I have to configure the save step as "overwrite once, then append" so I get a single file each time the project runs. How can I get Signal Express to either prompt the user for a new file name with each run or have the ascii file saved into the log directory for that run. As it stands now, the file gets overwritten with each new project run.
Thank you.
new userHi crawlejg,
You can set signal express to increment the file being created each time. But if you are looking for 1 new file each time the project runs you will have to use LabVIEW as this advanced functionality is not available in Signal Express. If you need help getting this to work in LabVIEW or have any other questions please feel free to ask!
Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support -
Mapping and loading single ASCII file into multiple tables in ODI
We get an ASCII file that contains several different transactions (records) and I need to validate and map each record to different table in the target database using Oracle Data Integrator tool. Is it possible ? If so, how and how difficult it is ?
I would appreciate a quick response.
Thanks,
RamHi Madha,
Using Demo version, we are trying to load data from ASCII file. When trying to execute, we are getting the following error:
7000 : null : com.sunopsis.jdbc.driver.file.a.icom.sunopsis.jdbc.driver.file.a.i
at com.sunopsis.jdbc.driver.file.a.f.getColumnClassName(f,java)
at com.sunopsis.sql.e.a(e.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execCollOrders(SnpSessTaskSql.java)
The file has all text fields and no date fields. we made sure that there is data for all fields being loaded.
Question is whether there is any problem in creating data in the Demo database which cameup with installation?
I mean, do we need to create any privileges to insert/add/delete ? We are running this as user SUPVERVISOR .
I appreciate if you can respond to this.
thanks,
Ram -
Making an ASCII file into a text file
Hi-
I am trying to read the lines of an ASCII file as Strings and write them to a new text file. Eventually I will modify the info in the lines, but for now I'm just trying to get the flow from one file to another. I can't figure out how to write a String to a new file. Below is the code that I've written so far, followed by the error that i get when I run it (it compiles fine). One problem I see is that FileWriters are made to write characters, but I want to write Strings to a new file. How do I get around this?
import java.io.*;
import java.lang.*;
import java.util.*;
class Delimiter {
public static void main (String[] args) throws IOException {
try {
File inputFile=new File("test.asc");
File outputFile=new File(test.txt");
BufferedReader in=new BufferedReader(new FileReader(inputFile));
BufferedWriter out=new BufferedWriter(new FileWriter(outputFile));
String line=" ";
while (line != null) {
line=in.readLine();
out.write(line);
out.newLine();
in.close();
out.close();
} catch (IOException e) {
ERROR:
Exception in thread "main" java.lang.NullPointerException
at java.io.Writer.write(Unknown Source)
at Delimiter.main(Delimiter.java:23)sorry, I responded too quickly. I put out.write(null);
just before the in.close(); statement and got an error
saying that command is ambiguous b/c write() could
belong to multiple classes. did you mean that I should
put it in the while loop?I didn't mean for you to put
out.write(null);
in your code. I meant to point out that when 'line' is null, the problem is that you are passing a null to the out.write() method. That is bad. Don't do that. Use the above. It will test for null before doing the write(). -
How to handle ASCII file in file download
Hi:
I have an applet that will download mutiple files to client's PC at the background. It handle binary files (e.g. word, excel) OK.
However, for ASCII file, it lost the line feeds, etc. so my multiple-lines file become 1 line (seems to be transfer via binary mode). Anyway to fix this ?
The relevant code segment looks like this:
public class Filedownload extends JApplet
public Filedownload()
String FileName1="template2.doc";
String webFile1 =
"http://hkzux05/~doracle/dev/"+FileName1;
String outfile1 =
"c://dev//mail-merge//" +FileName1;
String FileName2="data1.csv";
String webFile2 =
"http://hkzux05/~doracle/dev/"+FileName2;
String outfile2 =
"c://dev//mail-merge//" +FileName2;
try {
System.out.print("Start downloading file "+FileName1+"\n");
URL url = new URL(webFile1);
InputStream in = url.openStream();
byte[] buf = new byte[1024];
int len;
OutputStream out = new FileOutputStream(outfile1);
while ((len = in.read(buf)) != -1) {
//write byte to file
out.write(buf, 0, len);
//close the stream
in.close();
System.out.print("End downloading file "+FileName1+"\n");
System.out.print("Start downloading file "+FileName2+"\n");
url = new URL(webFile2);
in = url.openStream();
OutputStream out2 = new FileOutputStream(outfile2);
while ((len = in.read(buf)) != -1) {
//write byte to file
out2.write(buf, 0, len);
in.close();
System.out.print("End downloading file "+FileName2+"\n");
System.out.print("... Done ...\n");
catch (MalformedURLException e){
//TODO
catch (IOException e){
//TODO:FileNotFoundException caught here
finally{
//TODO
ThksCan anyone help ?
Thks -
Problem with flat file upload with ASCII file
Hi All,
I am trying to load data into an ODS object via PSA using a text file (tab delimited). I have the following settings in my InfoPackage
External Data tab: ASCII File
Seperator for thousands:
Character for decimal point:
Currency Conversion:
Number of Header rows to be ignored: 1
Processing tab: Only PSA and Update into data targets subsequently
When I do a preview the data is not showing up in the right format....the tab seperation does not work and data is garbled with extra hexadecimal characters too.
The same file contents in .csv format is loading the data in the right format and preview is fine too.
I need help trying to convert this csv file to .txt format.
Any clues are highly appreciated
Thank youHi,
If in the infopackage you click on a File Type ASCII-file (CR delimiter) radiobutton and then F1, youll see the help:
With an ASCII file as a data source, the data has to be available as a string in the format of the transfer structure. There are no data separators, empty characters are not ignored.
This means that:
- you shouldnt use any delimiters among the record fields
- all fields should have the length the system expects (length of the appropriate infoobject in transfer structure)
- each record should be separated from the next by carriage return CR.
Since I think the program that converts file from Excel format into CR-delimited would be very useful, I created such program in VBA.
So, open your Excel file (if you have csv-file you can open it using Excel).
The program assumes that the first row of the file contain field names. Data itself begin from the 2nd row. Insert as the 1st and 2nd rows the new, blank rows.
Into A1 cell insert number of the last row with data, into B1 number of the last column. Certainly, it may be determined in the program, but I have not done it if someone wants it, s/he can try it.
Into fields of the 2nd row insert expected length of the field.
Make sure that Visual Bacis toolbar is seen. (If not tick in menu path: View/Toolbars/Visual Basic).
In this toolbar click on a Design Node icon.
Drag from the toolbar and drop into worksheet a Command button element.
Double click on the button. In the open window for Private Sub CommandButton1_Click() subroutine insert the following code:
Dim ws1 As Worksheet
Dim J As Long, I As Long, L As Long
Dim FileName As String, Out As String, formatOut As String
Dim LenCell As Long
Set ws1 = ThisWorkbook.Worksheets("SHEET1")
FileName = ThisWorkbook.Path & "\" & Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 3) & "txt"
Open FileName For Output As #1
For J = 4 To ws1.Cells(1, 1)
Out = ""
For I = 1 To ws1.Cells(1, 2)
formatOut = (ws1.Cells(J, I))
L = Len(formatOut)
LenCell = Val(ws1.Cells(2, I))
If L > LenCell Then
formatOut = Left(formatOut, LenCell)
Else
Do While L < LenCell
formatOut = formatOut & " "
L = L + 1
Loop
End If
Out = Out & formatOut
Next
Print #1, Out
Next
Close #1
Set ws1 = Nothing
MsgBox "File transformation finished!", vbOKOnly
Now return to Excel sheet, click again Design Node icon switching into run mode.
When you press on this button now, the ASCII program will be created. It will have the same name as an input file (and in the same directory), but with TXT extention.
Remarks:
- The program works with the current worksheet named as SHEET1.
- Fields that are shorter than those expected by the system are padded by spaces from the right. It should not be the problem, since in transfer structure you can check symbols only flag.
- Longer fields are truncated to the length expected.
Best regards,
Eugene
Message was edited by: Eugene Khusainov -
Saving the content of JTable into a ascii file?
Suppose I have a JTable with certain cols and rows, is there an easy way to retrieve the table contents and save them into a ascii file on disk?
Thanks for your help.
helenIf colCount or rowCount is quite big, the "for loop" will spend some time to get the table content. Is there other way (not doing "for loops") to get the contents of JTable?
Thanks,
Helen
TableModel model = mytable.getModel()
PrintWriter writer = new
PrintWriter(BufferedWriter(new
FileWriter("test.dat")));
int colCount = col < model.getColumnCount();
int rowCount = model.getRowCount();
for (int row=0; row < rowCount; row++)
for (int col=0; col < colCount; col++)
Object value = model.getValueAt(row, col);
if (value != null)
ll) writer.print(value.toString());
if (col < rowCount - 1) writer.print("\t");
writer.println();
writer.close();What's so difficult with this, that the question pops
up every week ?
Thomas -
Insert time stamp in ASCII file
Hi all!
I am trying to log data values from several channels (so far 4) into one ASCII file including a time stamp in the first column.
The goal is one file that contains one time stamp per row (in the first column) and one column per channel. It may looks like this:
TIME Ch1 Ch2 Ch3 Ch4
t1 a1 b1 c1 d1
t2 a2 b2 c2 d2
I want to save one row (time stamp and 4 channels) each minute as above into the same file. Nice would be to creat a new file each day.
Problems:
1. Using the "Save to ASCII/LVM" step: How can I get SignalExpress to insert a time stamp in the first column of each row?
I have no problem inserting the 4 signals that generate me one column per signal. And using "Overwrite once, then append to file" I get one file for all signals.
Any idea how to insert a time stamp this way? Or how to creat a new file every 24 hours?
2. Another way I tried is to use the "Recording Option". But how can I get all the four signals saved in one file?
After the DAQmx acquisition step I process the 4 channels individually (one scaling step and one threshold step per channel - because of different factors per channel).
Activating the Recording Option (which would generate a new file every 24 hours, but not starting at 12pm each day...) I get 4 single TDMS-files (and their corresponding tdms_index and meta.txt files),
one file per signal I am recording. I assume this is because they are 4 individual signals I'm recording and not a group of signals. Can I group individual signals together?
Thanks for your help
SSC
PS: I work with SignalExpress 2.5 and have a NI USB-6210 connected.In the recording options tab you can set a stop condition to be 24 hours of data. And then select the "Restart Log Automatically" option to start logging for another 24 hours. You can also configure the logging to auto create an ASCII file once logging stops. With this configuration an ASCII file will be created every 24 hours. To enable ACSII file generation, select Tools>>Options.. And then set "Automatically export log to ASCII file to true".
I believe that you will get one ASCII file for each TDMS file. If you are logging 4 channels from the same device you should be able to log the entire group which would allow you to get only 1 TDMS / ASCII file. -
Read an ascii file line by line
I am new with CVI, and I need to read an ascii file with multiple lines in the following format:
at_test_2_to_13=0.861000
at_testabcd_9_to_21=0.712000
at_abdgx_5_to_8=0.892000
here is the code for writing in the ascii file:
sprintf(ctResult, "%s=%f\n", TestName1,result1);
WriteFile (fileHdl,ctResult ,StringLength(ctResult) );
At a later time, I need to read the text file, find the test name (for example "at_testabcd_9_to_21") and record the value after the "=" sign (in this case 0.712000). The number of lines in the text file is not fixed.
I am writing the data to the file with no problems, but I am stack in reading the data.
I would appreciate any help on how to write this code in CVI.
Thank you in advance
Solved!
Go to Solution.As Wolfgang already proposed, you can use the ini-file library.
With this library, you can write the results in a structured manner and access an individual measurement by its name, without the need of reading every line above.
I also attached a sample project for what you asked.
Check the ini-file library help and samples for the other option.
S. Eren BALCI
www.aselsan.com.tr
Attachments:
AsciiRead.zip 2 KB -
Data import from ASCII file : javasript to determine correct account
Hi,
I am importing data from an ASCII file and need to use a conversion file with javascript to determine the correct account depending on the amount I am importing.
As an example:
If external account B4711 carries an amount of 1000 it needs to be imported into internal account A890, if it carries an amount of -1000 it needs to be imported into internal account B890.
I have the VB script to do this in the MS version but am struggling with the javascript for the NW version.
In the transformation file, the account is the amount from the load file, the string | and the account from the load file. In my example I would get either 1000|B4711 or -1000|B4711. This part works fine.
The conversion file looks like this:
external internal formula
*|B4711 *IF(js:%external%.substring(0,1)=- then B890; A890)
The idea is, that if the first character is the minus sign, the conversion will return account B890, if it is any other character the conversionwill return A890. The actual result is that all data is imported into the account A890 irrespective of the amount (both positive and negative amounts).
Can anyone help me with this?
Thanks,
ArnoldHi Arnold,
Oh no! I thought this was going in the Formula column. I don't know how I got that idea.
So, I reviewed the documentation ([http://help.sap.com/saphelp_bpc75_nw/helpdata/en/81/94a8a5febd40268d5c59b4fc31be37/frameset.htm]) and you are correct that you should be able to use JS with the *IF statement - I was incorrect about that, at least according to the docs. In your original JS you probably just needed to use == instead of = and then put the minus sign in double-quotes
They also give an example of how to do it without JS, which I guess would look like
*If(%external%=-* then 242000; 128000)
So, that might work as well, though I'm not sure about how it's going to handle that minus sign.
Ethan
Maybe you are looking for
-
Heyo, So I'm punting as tech support in my office, and don't use TB myself. What's happening is on startup, a Bing settings page and the TB add-ons page are loading in tabs in addition to the inbox tab. X'ing the tabs individually does remove them, b
-
How to go back to the current jquery tabs
Hi, I have used Patric Wolf's method in (Re: New themes in APEX 4 not working with JQuery tabs to create the jquery tabs and it works great! Thank you Patric! Inside each tabs, I have a "create button" to branch to another form page to create some re
-
Error when import metadata: java.lang.ArrayIndexOutOfBoundsException: 1
hello i made changes to the mapping in DEV env; exported mdl and now im trying to import this mapping into TEST; i receive error message: Error at line 8,487: MDL1261: Error importing MAPPING xxxx Detailed Error Message: java.lang.ArrayIndexOutOfBoun
-
Why do I have to re-enter my password for my wireless router?
I bought my brand new Macbook Pro yesterday and am pretty disappointed. Can someone please explain in very basic terms, how to keep my Mac connected to the internet? Every time I attempt to connect to the internet, I'm asked to enter my password for
-
Lightroom and Camera Raw 3.7 discrepancy
After I process am image in Lightroom 1.0, I look to see if any highlights are burned out. Then if I open the same image in Camera Raw 3.7, it shows a considerably higher degree of highlights being burned out than Lightroom does. Has anyone noticed t