Open Excel read and write problem
I am trying to deterimine what is causing excel files to open up as "Read Only" using Labview, when I excplicitly state to open as "ReadWrite"
It seems to work well in the development environment, but not so well on some PCs in the application environment.
Attachments:
lv_excel.jpg 122 KB
Are you using a template file? Is the file marked as "read only"?
Do you or the application has proper admin rights in the PC where it used?
Guru
Regards
Guru (CLA)
Similar Messages
-
Windows 2008 R2 Folder assign permission "Read and Write" problem with *.doc file
Hello All,
I am a new one here,
I am sorry for any mistakes and also my english is so poor.
M Brother company runing Windows 2008 R2 as Active Directory...
We have folder Name: Admin
and in this folder, there are alot documents files as : *.doc, *.dwg, *.txt etc.....
All user accesing to these files and they can open to edit and save...
One day my brother want me to set Admin folder for all users just"Read and Write.." mean they still can open files to edit and save... but can't delete..
I did success with this..
But only one thing happen.. when they open *.doc file to edit and attempting to save, the message alert" access denide " and they can only "SAVE AS"...We don't want "Save as"
Could you show me how can we fix error with *.doc file while they trying to save? because it allow only save as.. but other files as *.text file or *.dwg they can save without problem..
Could expert here ever face this issues and fix by yourself, please share me with this..
Please help me..
Best regards,Hi,
Office programs are specific. They will create a temp file when edit, then the temp file will be deleted when close. So Delete permission is needed for users to saving Office files like Excel/Word.
For more detaile information, please refer to the thread below:
Special Permissions - User cannot save files
http://social.technet.microsoft.com/Forums/windowsserver/en-US/721fb2f1-205b-46e5-a3dc-3029e5df9b5b/special-permissions-user-cannot-save-files
Best Regards,
Mandy
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected] -
PXI-6508 Read and Write Problem
Hi,
I have two PXI-6508 DAQ cards. I am using one for inputs and one for outputs. Using read data socket vi I am able to read from the input card, and using write data socket I am able to write to the output card. I am configuring one card to read and one to write, both work seperatly but when I put both vi into my application it crashes and refuses to work. I then need to reboot my PC to then start again. What am I doing wrong?Hi gedsy
I guess you are using some ressources at the same time. The ressource can be a VI or a refnum or any other thing of this kind.
You should check you are not using the same vis and expect different dataspaces. If you want to use different data spaces with same VIs, you must set them as re-entrant.
Doc-Doc
Doc-Doc
http://www.machinevision.ch
http://visionindustrielle.ch
Please take time to rate this answer -
Hello!
I have a problem with the Data I/O in my program. The button "Animation" generates random numbers and saves them into a file. With the Button "Vergleich" i want to load the data and reproduce the data in the graph.
When i push the button "Vergleich" i can choose the data, but the program don*t reproduces it!
Coult anybody help me??
TNKS
Best regards,
Peter
Labview 7.1 on Windows 2000
Attachments:
program.vi 68 KBHere are two changes, one uses the write to spreadsheet and read from spreadsheet file functions, the other changes your "read file" to "read text file"
P.M.
Putnam
Certified LabVIEW Developer
Senior Test Engineer
Currently using LV 6.1-LabVIEW 2012, RT8.5
LabVIEW Champion
Attachments:
program[1.x].zip 41 KB -
Rs232 read and write from pressure transducer with command.
New to LabVIEW and have my first task. I have connected to a Setra pressure transducer via rs232 in Com port 4. I'm trying to track and log pressure over a given period of time. A command of "P" must be sent to the transducer for it to return a pressure reading. By searching, so far I have VISA open, close, read and write on my block diagram. I tried to create a constant from the VISA read resource name and connect it to COM4, but that did not work. Not sure how to accomplish my goal or how to wire everything up correctly. Any help for a beginner is appreciated.
That error is due to some process already having exclusive rights to the port. Do you have Hyperterminal or something else the could be using the COM port open? Did you not close out the VISA reference during previous runs?
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines -
Read and write excel sheet data from uploded file in sharepoint site programmatically 2013
hi team,
I am working on sharepoint 2013.I want to read and write data in excel sheet (micrsoft excel) from stored file in shrepoint docoumnt library .please suggest me
vijayHi
Vijay,
check those links
http://www.sharepointwithattitude.com/archives/61
https://social.technet.microsoft.com/Forums/en-US/e760051b-a92f-473c-9ec9-0f0c36c99e40/read-and-write-excel-sheet-data-from-uploded-file-in-sharepoint-site-programmatically-2013?forum=sharepointdevelopment
Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation. Please remember to mark the reply as answer if it helps. -
having problems opening a pdf file with reader 10/11 get error msg cannot open close reader and try again any ideas
Hi George ,
Is it happening with all the PDF' or any specific one?
Could you please share the error message so that we can replicate at our end ?
Try repairing reader once and see if that fixes the issue.
Launch Reader>Navigate to Help>Repair Adobe Reader Installation
Regards
Sukrit Dhingra -
How to read and write data in to a specified range of cells(it include multiple row & columns) in excel
CVI Comes with a sample project that explains how to read/write to a Excel file: choose "Explore examples..." in CVI welcome page and navigate to <cviSampleDir>\activex\excel folder where you can load excel2000dem.prj.
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
I have an excel file,i want to read and write this file to xml
hello,
i have an excel file,i want to read excel data and write to xml file .i also have an exisitng xml file and i want to appened the excel data to the exisiting xml.please give some example code.
thanksGoOgLe
-
Multithreaded problem in read and write thread
This is a producer consumer problem in a multi-threaded environment.
Assume that i have multiple consumer (Multiple read threads) and a
single producer(write thread).
I have a common data structure (say an int variable), being read and written into.
The write to the data sturcture happens occasionally (say at every 2 secs) but read happens contineously.
Since the read operation is contineous and done by multiple threads, making the read method synchronized will add
overhead(i.e read operation by one thread should not block the other read threads). But when ever write happens by
the write thread, that time the read operations should not be allowed.
Any ideas how to achive this ??If all you're doing is reading an int, then just use regular Java synchronization. You'll actually get a performance hit if you're doing simple read operations, as stated in the ReadWriteLock documentation:
Whether or not a read-write lock will improve performance over the use of a mutual exclusion lock depends on the frequency that the data is read compared to being modified, the duration of the read and write operations, and the contention for the data - that is, the number of threads that will try to read or write the data at the same time. For example, a collection that is initially populated with data and thereafter infrequently modified, while being frequently searched (such as a directory of some kind) is an ideal candidate for the use of a read-write lock. However, if updates become frequent then the data spends most of its time being exclusively locked and there is little, if any increase in concurrency. Further, if the read operations are too short the overhead of the read-write lock implementation (which is inherently more complex than a mutual exclusion lock) can dominate the execution cost, particularly as many read-write lock implementations still serialize all threads through a small section of code. Ultimately, only profiling and measurement will establish whether the use of a read-write lock is suitable for your application. -
Problem with air read and write smb shared directory of file
hi, everyone.
I'm want to access smb directory of file,And to read and
write operation, I would like to ask how I should do?
Thanks!You can't access any OS facility nor execute arbitrary command.
So the best solution is to mount samba directory BEFORE run your AIR application; you eventually can create a script that mount samba (and asks password) and then run you AIR application.
see
http://www.mikechambers.com/blog/2008/01/17/commandproxy-net-air-integration-proof-of-conc ept/
for a more complex solution. -
Why does this class not read and write at same time???
I had another thread where i was trying to combine two class files together
http://forum.java.sun.com/thread.jspa?threadID=5146796
I managed to do it myself but when i run the file it does not work right. If i write a file then try and open the file it says there are no records in the file, but if i close the gui down and open the file everything get read in as normal can anybody tell me why?
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import bank.BankUI;
import bank.*;
public class testing extends JFrame {
private ObjectOutputStream output;
private BankUI userInterface;
private JButton SaveToFile, SaveAs, Exit; //////////savetofile also saves to store need to split up and have 2 buttons
//private Store store; MIGHT BE SOMETHING TO DO WITH THIS AS I HAD TO COMMENT THIS STORE OUT TO GET IT WORKING AS STORE IS USED BELOW
private Employee record;
//////////////////////////////////////from read
private ObjectInputStream input;
private JButton nextButton, openButton, nextRecordButton ;
private Store store = new Store(100);
private Employee employeeList[] = new Employee[100];
private int count = 0, next = 0;
/////////////////////////////////////////////from read end
// set up GUI
public testing()
super( "Employee Data" ); // appears in top of gui
// create instance of reusable user interface
userInterface = new BankUI( 9 ); // nine textfields
getContentPane().add( userInterface, BorderLayout.CENTER );
// configure button doTask1 for use in this program
SaveAs = userInterface.getSaveAsButton();
SaveAs.setText( "Save as.." );
//////////////////from read
openButton = userInterface.getOpenFileButton();
openButton.setText( "Open File" );
openButton.addActionListener(
// anonymous inner class to handle openButton event
new ActionListener() {
// close file and terminate application
public void actionPerformed( ActionEvent event )
openFile();
} // end anonymous inner class
); // end call to addActionListener
// register window listener for window closing event
addWindowListener(
// anonymous inner class to handle windowClosing event
new WindowAdapter() {
// close file and terminate application
public void windowClosing( WindowEvent event )
if ( input != null )
closeFile();
System.exit( 0 );
} // end anonymous inner class
); // end call to addWindowListener
// get reference to generic task button doTask2 from BankUI
nextButton = userInterface.getDoTask2Button();
nextButton.setText( "Next Record" );
nextButton.setEnabled( false );
// register listener to call readRecord when button pressed
nextButton.addActionListener(
// anonymous inner class to handle nextRecord event
new ActionListener() {
// call readRecord when user clicks nextRecord
public void actionPerformed( ActionEvent event )
readRecord();
} // end anonymous inner class
); // end call to addActionListener
//get reference to generic task button do Task3 from BankUI
// get reference to generic task button doTask3 from BankUI
nextRecordButton = userInterface.getDoTask3Button();
nextRecordButton.setText( "Get Next Record" );
nextRecordButton.setEnabled( false );
// register listener to call readRecord when button pressed
nextRecordButton.addActionListener(
// anonymous inner class to handle nextRecord event
new ActionListener() {
// call readRecord when user clicks nextRecord
public void actionPerformed( ActionEvent event )
getNextRecord();
} // end anonymous inner class
); // end call to addActionListener
///////////from read end
// register listener to call openFile when button pressed
SaveAs.addActionListener(
// anonymous inner class to handle openButton event
new ActionListener() {
// call openFile when button pressed
public void actionPerformed( ActionEvent event )
SaveLocation();
} // end anonymous inner class
); // end call to addActionListener
// configure button doTask2 for use in this program
SaveToFile = userInterface.getSaveStoreToFileButton();
SaveToFile.setText( "Save to store and to file need to split this task up" );
SaveToFile.setEnabled( false ); // disable button
// register listener to call addRecord when button pressed
SaveToFile.addActionListener(
// anonymous inner class to handle enterButton event
new ActionListener() {
// call addRecord when button pressed
public void actionPerformed( ActionEvent event )
addRecord(); // NEED TO SPLIT UP SO DONT DO BOTH
} // end anonymous inner class
); // end call to addActionListener
Exit = userInterface.getExitAndSaveButton();
Exit.setText( "Exit " );
Exit.setEnabled( false ); // disable button
// register listener to call addRecord when button pressed
Exit.addActionListener(
// anonymous inner class to handle enterButton event
new ActionListener() {
// call addRecord when button pressed
public void actionPerformed( ActionEvent event )
addRecord(); // adds record to to file
closeFile(); // closes everything
} // end anonymous inner class
); // end call to addActionListener
// register window listener to handle window closing event
addWindowListener(
// anonymous inner class to handle windowClosing event
new WindowAdapter() {
// add current record in GUI to file, then close file
public void windowClosing( WindowEvent event )
if ( output != null )
addRecord();
closeFile();
} // end anonymous inner class
); // end call to addWindowListener
setSize( 600, 500 );
setVisible( true );
store = new Store(100);
} // end CreateSequentialFile constructor
// allow user to specify file name
////////////////from read
// enable user to select file to open
private void openFile()
// display file dialog so user can select file to open
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
int result = fileChooser.showOpenDialog( this );
// if user clicked Cancel button on dialog, return
if ( result == JFileChooser.CANCEL_OPTION )
return;
// obtain selected file
File fileName = fileChooser.getSelectedFile();
// display error if file name invalid
if ( fileName == null || fileName.getName().equals( "" ) )
JOptionPane.showMessageDialog( this, "Invalid File Name",
"Invalid File Name", JOptionPane.ERROR_MESSAGE );
else {
// open file
try {
input = new ObjectInputStream(
new FileInputStream( fileName ) );
openButton.setEnabled( false );
nextButton.setEnabled( true );
// process exceptions opening file
catch ( IOException ioException ) {
JOptionPane.showMessageDialog( this, "Error Opening File",
"Error", JOptionPane.ERROR_MESSAGE );
} // end else
} // end method openFile
public void readRecord() // need to merger with next record
Employee record;
// input the values from the file
try {
record = ( Employee ) input.readObject();
employeeList[count++]= record;
store.add(record);/////////ADDS record to Store
store.displayAll();
System.out.println("Count is " + store.getCount());
// create array of Strings to display in GUI
String values[] = {
String.valueOf(record.getName()),
String.valueOf(record.getGender()),
String.valueOf( record.getDateOfBirth()),
String.valueOf( record.getID()),
String.valueOf( record.getStartDate()),
String.valueOf( record.getSalary()),
String.valueOf( record.getAddress()),
String.valueOf( record.getNatInsNo()),
String.valueOf( record.getPhone())
// i added all those bits above split onto one line to look neater
// display record contents
userInterface.setFieldValues( values );
// display message when end-of-file reached
catch ( EOFException endOfFileException ) {
nextButton.setEnabled( false );
nextRecordButton.setEnabled( true );
JOptionPane.showMessageDialog( this, "No more records in file",
"End of File", JOptionPane.ERROR_MESSAGE );
// display error message if class is not found
catch ( ClassNotFoundException classNotFoundException ) {
JOptionPane.showMessageDialog( this, "Unable to create object",
"Class Not Found", JOptionPane.ERROR_MESSAGE );
// display error message if cannot read due to problem with file
catch ( IOException ioException ) {
JOptionPane.showMessageDialog( this,
"Error during read from file",
"Read Error", JOptionPane.ERROR_MESSAGE );
} // end method readRecord
private void getNextRecord()
Employee record = employeeList[next++%count];//cycles throught accounts
//create aray of string to display in GUI
String values[] = {String.valueOf(record.getName()),
String.valueOf(record.getGender()),
String.valueOf( record.getStartDate() ), String.valueOf( record.getAddress()),
String.valueOf( record.getNatInsNo()),
String.valueOf( record.getPhone()),
String.valueOf( record.getID() ),
String.valueOf( record.getDateOfBirth() ),
String.valueOf( record.getSalary() ) };
//display record contents
userInterface.setFieldValues(values);
//display record content
///////////////////////////////////from read end
private void SaveLocation()
// display file dialog, so user can choose file to open
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
int result = fileChooser.showSaveDialog( this );
// if user clicked Cancel button on dialog, return
if ( result == JFileChooser.CANCEL_OPTION )
return;
File fileName = fileChooser.getSelectedFile(); // get selected file
// display error if invalid
if ( fileName == null || fileName.getName().equals( "" ) )
JOptionPane.showMessageDialog( this, "Invalid File Name",
"Invalid File Name", JOptionPane.ERROR_MESSAGE );
else {
// open file
try {
output = new ObjectOutputStream(
new FileOutputStream( fileName ) );
SaveAs.setEnabled( false );
SaveToFile.setEnabled( true );
Exit.setEnabled( true );
// process exceptions from opening file
catch ( IOException ioException ) {
JOptionPane.showMessageDialog( this, "Error Opening File",
"Error", JOptionPane.ERROR_MESSAGE );
} // end else
} // end method openFile
// close file and terminate application
private void closeFile()
// close file
try {
//you want to cycle through each recordand add them to store here.
int storeSize = store.getCount();
for (int i = 0; i<storeSize;i++)
output.writeObject(store.elementAt(i));
output.close();
input.close();// from read!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
System.exit( 0 );
// process exceptions from closing file
catch( IOException ioException ) {
JOptionPane.showMessageDialog( this, "Error closing file",
"Error", JOptionPane.ERROR_MESSAGE );
System.exit( 1 );
} // end method closeFile
// add record to file
public void addRecord()
int employeeNumber = 0;
String fieldValues[] = userInterface.getFieldValues();
// if account field value is not empty
if ( ! fieldValues[ BankUI.IDNUMBER ].equals( "" ) ) {
// output values to file
try {
employeeNumber = Integer.parseInt(
fieldValues[ BankUI.IDNUMBER ] );
String dob = fieldValues[ BankUI.DOB ];
String[] dateofBirth = dob.split ("-"); // what used to put between number chnage to /
String sDate = fieldValues[ BankUI.START ];
String[] startDate = sDate.split ("-");
String sex = fieldValues[ BankUI.GENDER ];
char gender = (sex.charAt(0)); // check if m or f prob check in employee
if ( employeeNumber >= 0 ) {
/* create new record =String name, char gender, Date dob, String add, String nin, String phone, String id, Date start, float salary*/
record = new Employee(
fieldValues[ BankUI.NAME ],
gender,
new Date( Integer.parseInt(dateofBirth[0]),
Integer.parseInt(dateofBirth[1]),
Integer.parseInt(dateofBirth[2])),
fieldValues[ BankUI.ADDRESS ],
fieldValues[ BankUI.NATINTNO ],
fieldValues[ BankUI.PHONE ],
fieldValues[ BankUI.IDNUMBER ],
new Date( Integer.parseInt(startDate[0]),
Integer.parseInt(startDate[1]),
Integer.parseInt(startDate[2])),
Float.parseFloat( fieldValues[ BankUI.SALARY ] ));
if (!store.isFull())
store.add(record);
else
JOptionPane.showMessageDialog( this, "The Store is full you cannot add\n"+
"anymore employees. \nPlease Save Current File and Create a New File." );
System.out.println("Store full");
store.displayAll();
System.out.println("Count is " + store.getCount());
// output record and flush buffer
//output.writeObject( record );
output.flush();
else
JOptionPane.showMessageDialog( this,
"Account number must be greater than 0",
"Bad account number", JOptionPane.ERROR_MESSAGE );
// clear textfields
userInterface.clearFields();
} // end try
// process invalid account number or balance format
catch ( NumberFormatException formatException ) {
JOptionPane.showMessageDialog( this,
"Bad ID number, Date or Salary", "Invalid Number Format",
JOptionPane.ERROR_MESSAGE );
// process exceptions from file output
catch ( ArrayIndexOutOfBoundsException ArrayException ) {
JOptionPane.showMessageDialog( this, "Error with Start Date or Date of Birth\nPlease enter like: 01-01-2001",
"IO Exception", JOptionPane.ERROR_MESSAGE );
// process exceptions from file output
catch ( IOException ioException ) {
JOptionPane.showMessageDialog( this, "Error writing to file",
"IO Exception", JOptionPane.ERROR_MESSAGE );
closeFile();
} // end if
} // end method addRecord
public static void main( String args[] )
new testing();
} // end class CreateSequentialFileSure you can read and write at the same time. But normally you would be reading from one place and writing to another place.
I rather regret avoiding the OP's earlier post asking how to combine two classes. I looked at the two classes posted and realized the best thing to do was actually to break them into more classes. But I also realized it was going to be a big job explaining why and how, and I just don't have the patience for that sort of thing.
So now we have a Big Ball Of Tar™ and I feel partly responsible. -
I am running FF 18.0.2 on a Win7 system with an i7 CPU and 8GB RAM. My Flash plugin is newly-updated. I've used Firefox on this machine its entire life (3 years).
Since 3 or 4 (?) versions ago, I've been getting massive activity on my hard drive with Firefox. When I check with Win Task Manager, I see the plugin-container.exe *32 and the FlashPlayerPlugin_11_5_502_149.exe *32 processes are generating millions of I/O reads and writes, even while Firefox is idle (minimized, running no audio or video). On this latest version, 18.0.2, the drive activity stalls out YouTube videos repeatedly, even though I can see they're buffered ahead. The playing video will stop, audio will continue to end of buffer, and then EVERYTHING stops (Firefox not responding) for 30 seconds or so. It will then pickup again and play until it repeats the same pattern in a minute or so.
Example: I closed and restarted Firefox 2 days ago. Earlier today I checked Windows Task Manager and found the two processes EACH generated about 161 million reads and 141 million writes since then! My wife's laptop is showing nothing like a hundredth of that.
The constant drive activity is slowing down all programs outside of Firefox too, as you might imagine. The PC is acting like it's a dedicated machine for Flash.The Reset Firefox feature can fix many issues by restoring Firefox to its factory default state while saving your essential information.
Note: ''This will cause you to lose any Extensions, Open websites, and some Preferences.''
To Reset Firefox do the following:
#Go to Firefox > Help > Troubleshooting Information.
#Click the "Reset Firefox" button.
#Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
#Firefox will open with all factory defaults applied.
Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
Did this fix your problems? Please report back to us! -
I cannot update from OS X 10.9.4 t0 10.9.5> Whenever I try I get the following message: File couldn't be installed error (513) and something about not having the proper permission. Under the Macintosh HD sharing and permissions settings I have customized the settings so that (Me) has read and write permission followed by the system with read and write permission, wheel and everyone have Read permissions.
I have no problems updating apps such as Adobe CC or iTunes but cannot update the operating system, can someone help me? Thanks.1. Restart the computer in safe mode. Certain caches maintained by the system will be rebuilt.
Safe mode is much slower to start up than normal. The next normal startup may also be somewhat slow.
When the login screen appears, restart as usual (not in safe mode) and test. There's no need to log in while in safe mode.
Note: If FileVault is enabled, or if a firmware password is set, or if the startup volume is a software RAID, you can’t start in safe mode. In that case, go to Step 2.
If there's no change after taking this step, continue.
2. Back up all data before proceeding.
Triple-click anywhere in the line below on this page to select it:
/var/folders
Right-click or control-click the highlighted line and select
Services ▹ Reveal in Finder (or just Reveal)
from the contextual menu.* A folder should open with an item named "folders" selected. Move the selected item to the Trash. You may be prompted for your administrator login password. Restart the computer and empty the Trash.
*If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination command-C. In the Finder, select
Go ▹ Go to Folder...
from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return. -
Can you improve the speed of my CSV Reader and Writer?
hi all, i'm trying to develop a CSV Writer and Reader. i have done a good work to implement the special character and quoting it, it's also support multi line value but it's incredibly slow.
can someone help to make it faster?
here it's how to use the writer
char *stringhe_sorgenti[10] = {0};
out = OpenFile(nfile, VAL_WRITE_ONLY, VAL_TRUNCATE, VAL_ASCII);
for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
stringhe_sorgenti[i] = (char*)calloc(200, sizeof(char));
sprintf(stringhe_sorgenti[0], "example1");
sprintf(stringhe_sorgenti[1], "example2");
scrivi_riga_csv(out, stringhe_sorgenti, sizeof(stringhe_sorgenti)/sizeof(char*), formato);
for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
free(stringhe_sorgenti[i]);
CloseFile(out);
here is the writer
void scrivi_riga_csv(int file_handle, char *stringa_sorgente[], int numero_stringhe, int formato)
char delimitatore[2][2] = {{',', '\0'}, {';', '\0'}};
char stringa_destinazione[1024] = {0};
int index_destinazione = {0};
int index_start = {0};
int index_fine = {0};
int errore = {0};
int i = {0};
//int k = {0};
size_t lunghezza_stringa = {0};
for(i = 0; i < numero_stringhe; i++){
if(i != 0){
stringa_destinazione[index_destinazione++] = delimitatore[formato][0];
index_start = 0;
lunghezza_stringa = strlen(stringa_sorgente[i]);
// se la stringa sorgente
if( (FindPattern(stringa_sorgente[i], 0, lunghezza_stringa, delimitatore[formato], 0, 0) != -1) // contiene delimitatore
|| (FindPattern(stringa_sorgente[i], 0, lunghezza_stringa, "\"", 0, 0) != -1) // contiene parentesi
|| (FindPattern(stringa_sorgente[i], 0, lunghezza_stringa, "\n", 0, 0) != -1) // contiene a capo
// apro parentesi all'inizio
stringa_destinazione[index_destinazione++] = '"';
// metodo find pattern, piu' complesso ma piu' performante
do{ index_fine = FindPattern(stringa_sorgente[i], index_start, lunghezza_stringa - index_start, "\"", 0, 0);
if(index_fine != -1){
index_fine++;
// copio dall'inizio fino alle virgolette
CopyString (stringa_destinazione, index_destinazione, stringa_sorgente[i], index_start, index_fine - index_start);
index_destinazione += index_fine - index_start;
// ne aggiungo una dopo
stringa_destinazione[index_destinazione++] = '"';
// aggiorno la posizione di start e riparto con il while
index_start = index_fine;
}while(index_fine != -1);
CopyString (stringa_destinazione, index_destinazione, stringa_sorgente[i], index_start, lunghezza_stringa - index_start);
index_destinazione += strlen(stringa_sorgente[i]) - index_start;
// alla fine della riga chiudo la parentesi
stringa_destinazione[index_destinazione++] = '"';
else{
// altrimenti la copio semplicemente e shifto l'indice della stringa di destinazione
CopyString (stringa_destinazione, index_destinazione, stringa_sorgente[i], 0, lunghezza_stringa);
index_destinazione += strlen(stringa_sorgente[i]);
memset(stringa_sorgente[i], 0, strlen(stringa_sorgente[i]));
errore = WriteLine (file_handle, stringa_destinazione, strlen(stringa_destinazione));
if(errore == -1){
errore = GetFmtIOError();
MessagePopup("WriteLine -> WriteLine", GetFmtIOErrorString(errore));
return;
here how to read the file
char *stringhe_sorgenti[10] = {0};
for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
stringhe_sorgenti[i] = (char*)calloc(200, sizeof(char));
out = OpenFile(nomearchivio, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_BINARY);
leggi_riga_csv(out, stringhe_sorgenti, sizeof(stringhe_sorgenti)/sizeof(char*), formato);
strcpy(intestazione.data, stringhe_sorgenti[1]);
for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
free(stringhe_sorgenti[i]);
CloseFile(out);
and here the reader
void leggi_riga_csv(int file_handle, char *stringa_destinazione[], int numero_stringhe, int formato)
char delimitatore[2][2] = {{',', '\0'},
{';', '\0'}};
char stringa_sorgente[1024] = {0};
int stringa_in_corso = {0};
int index_inizio_valore = {0};
int index_doublequote = {0};
int offset_stringa_destinazione = {0};
size_t lunghezza_stringa = {0};
int inquote = {0};
int errore = {0};
int i = {0};
for(i = 0; i < numero_stringhe; i++){
lunghezza_stringa = strlen(stringa_destinazione[i]);
memset(stringa_destinazione[i], 0, lunghezza_stringa);
do{ memset(&stringa_sorgente, 0, sizeof(stringa_sorgente));
errore = ReadLine(file_handle, stringa_sorgente, sizeof(stringa_sorgente) - 1);
// If ReadLine reads no bytes because it has already reached the end of the file, it returns –2.
// If an I/O error occurs, possibly because of a bad file handle, ReadLine returns –1.
// You can use GetFmtIOError to get more information about the type of error that occurred.
// A value of 0 indicates that ReadLine read an empty line.
if(errore == -1){
errore = GetFmtIOError();
MessagePopup("leggi_riga_csv -> ReadLine", GetFmtIOErrorString(errore));
return;
else if(errore == -2){
errore = GetFmtIOError();
MessagePopup("leggi_riga_csv -> ReadLine", "already reached the end of the file");
return;
else{
lunghezza_stringa = errore;
index_inizio_valore = 0;
// metodo find pattern, piu' complesso ma piu' performante
for(i = 0; i <= lunghezza_stringa; i++){
// se come primo carattere ho una " allora e' una stringa speciale
if(inquote == 0){
if(stringa_sorgente[i] == '\"'){
inquote = 1;
index_inizio_valore = ++i;
else{
// altrimenti cerco il delimitatore senza il ciclo for
i = FindPattern(stringa_sorgente, i, lunghezza_stringa - index_inizio_valore, delimitatore[formato], 0, 0);
if(i == -1){
// se non lo trovo ho finito la riga
i = lunghezza_stringa;
if(stringa_sorgente[i - 1] == '\r'){
i--;
if(stringa_in_corso < numero_stringhe){
CopyString (stringa_destinazione[stringa_in_corso], 0, stringa_sorgente, index_inizio_valore, i - index_inizio_valore);
offset_stringa_destinazione = 0;
stringa_in_corso++;
if(stringa_sorgente[i] == '\r'){
i++;
index_inizio_valore = i + 1;
if(inquote == 1){
// se sono nelle parentesi cerco le virgolette
i = 1 + FindPattern(stringa_sorgente, i, lunghezza_stringa - index_inizio_valore, "\"", 0, 0);
if(i == 0){
if(stringa_sorgente[lunghezza_stringa - 1] == '\r'){
lunghezza_stringa--;
// se non le trovo ho finito la riga, esco dal ciclo for
break;
// se incontro una doppia parentesi salto avanti
else if(stringa_sorgente[i] == '\"'){
continue;
// !!!! fondamentale non cambiare l'ordine di questi else if !!!!!
// se incontro una parentesi seguita dal delimitatore
// o se incontro una parentesi seguita dal terminatore
// \r = CR = 0x0D = 13
// \n = LF = 0x0A = 10
// a capo = CR + LF
else if( (stringa_sorgente[i] == delimitatore[formato][0])
|| (stringa_sorgente[i] == '\r')
|| (stringa_sorgente[i] == '\0')
// salvo il valore
inquote = 0;
if(stringa_in_corso < numero_stringhe){
CopyString (stringa_destinazione[stringa_in_corso], offset_stringa_destinazione, stringa_sorgente, index_inizio_valore, i - 1 - index_inizio_valore);
offset_stringa_destinazione = 0;
stringa_in_corso++;
if(stringa_sorgente[i] == '\r'){
i++;
index_inizio_valore = i;
// se sono andato a capo scrivo fino a dove sono e poi procedo con la nuova riga
if(inquote){
if(stringa_in_corso < numero_stringhe){
CopyString (stringa_destinazione[stringa_in_corso], offset_stringa_destinazione, stringa_sorgente, index_inizio_valore, lunghezza_stringa - index_inizio_valore);
strcat(stringa_destinazione[stringa_in_corso], "\n");
offset_stringa_destinazione += lunghezza_stringa - index_inizio_valore;
offset_stringa_destinazione++;
}while(inquote == 1);
// elimino le doppie parentesi
for(i = 0; i < numero_stringhe; i++){
index_doublequote = 0;
do{ lunghezza_stringa = strlen(stringa_destinazione[i]);
index_doublequote = FindPattern(stringa_destinazione[i], index_doublequote, lunghezza_stringa - index_doublequote, "\"\"", 0, 0); // contiene doppia parentesi
if(index_doublequote != -1){
index_doublequote++;
memmove (stringa_destinazione[i] + index_doublequote, stringa_destinazione[i] + index_doublequote + 1, lunghezza_stringa - index_doublequote);
}while(index_doublequote != -1);
return;the format is CSV, i try to explain better what i'm doing.
our client asked to save acquisition data with header description in an excel readable format, i've decided to use .CSV and not .TDM because it's a simple txt file and we never used .TMD but i will propose to use it.
after some research on the internet i've found nothing to handle .CSV in CVI except from this csv_parse but i've found it difficult to be maintained so i've write it by my own hand.
i've written two example of how to use my function to read or write and i've copyed my function used to read and write.
in the write function i check with FindPattern if the string to be write contain some special character, if i find this i have to quote the string to respect the standard RFC4180 and if i find a quote i have to double it. aftere i've done this check i write the line in the file.
in the read function, that is more complicated, i:
check if the first character is a quote.
if it's not i copy the string until the delimitier or until the end of the line.
if it is i have a string with special character inside so:
i find the first quote in the string. when i've found i check if it's follwed by another quote. this means that in the starting message i was writing a single quote.
if it's not followed by another quote but it's followed by a delimiter or a carriage return i've finished the special line.
if i don't find it it means that the special quote have a carriage return inside and i have to check the next line. before checking the next line i save this in my string.
after this loop i check in every string if i have a double quote and i delete one.
the main problem is in the speed of this, i'm acquiring data at 1000 S/s with 8 active channel for 60 second so i have 480000 data to be stored, divided in 60.000 row and 8 column. to read a file like that my pc stay "locked" for 15 second or more.
i've tried to use the arraytofile function and it's extremly fast and i can also put header because the function can start from the last position in the file but the filetoarray function start from the beginning and i cannot read the header correctly. also if i'm using the european CSV with semicolon as delimiter with arraytofile i cannot select the semicolon but only the coma
Maybe you are looking for
-
Open in Tabs always replaces all other open tabs ?
This is unacceptable. Suppose I have 5 open tabs and then I pres Open in Tabs (this command is available on the Toolbar when I create collections) This will close down all the 5 open tabs and replace them with the tabs in the folder!! I want to keep
-
Can iphone receive audio bluetooth?
As we all know, the iPhone can TRANSMIT audio via bluetooth, but is it possible for the iPhone to also RECEIVE audio? Particularly from a TV or computer (assuming they also have BT)? Reason I ask is that I was looking into buying bluetooth headphon
-
Help - Adobe Photoshop Starter Edition 3.2 - Unlocking
Hi, I know there are alot of questions on here about the same thing but I need some help!. I have lots of photos in the starter edition which is asking me to register but will not connect to the internet and I just can't get them out. I have looked e
-
Regarding STATUS FIELD INFORMATION OF T.CODE CO03(Display Production Order)
Hello Friends, I want to know, how could i get the Status field information from T.CodeCO03(Display Production Order). Any F.M or Table Name. I have production order Number as input field and output will be Status. Regards Amit
-
Opening a random file in Applescript is not really random
Hi all, I'm not very experienced in Applescript, but I was trying to help a friend write a quick script that opens a random mp3 from an external harddrive (don't ask me why he's not using iTunes). The problem is, that when he plugs his hard drive in