fread error? invalid file identifier - excel

while executing, I have this error ?? Error using ==> fread
Invalid file identifier. Use fopen to generate a valid file identifier. fid is equal to -1 but the file does exist.
what shall I do?
seq=dir('C:\Windows\system32\config\systemprofile\Desktop\pfe\code final version 1\nor\info');
N=[];
for i = 3 : length(seq)
disp(seq(i).name)
cd 'C:\Windows\system32\config\systemprofile\Desktop\pfe\code final version 1\nor\info'
fin = fopen('seq(i).name','r');
[x,count]=fread(fin,'char=>char');
cd 'C:\Windows\system32\config\systemprofile\Desktop\pfe\code final version 1'
M=fichier(fin,x);
N=[N;M];
end
xlswrite('info.xls',N);

As you put '' around the name, you are trying to open a file called seq(i).name, remove the '' and you are using the variable named seq(i).name
fin = fopen(seq(i).name,'r');

Related

Import SSL certificate by certutil in InstallShield

I have a function as below :
function LONG ImportSSL(hMSI)
STRING exeDir;
STRING sslDir;
NUMBER nvSize;
LONG ret;
begin
nvSize = 256;
MsiGetProperty (hMSI, "SETUPEXEDIR", exeDir, nvSize);
sslDir = exeDir ^ "ssl\\myCertificate.pfx";
ret = LaunchAppAndWait(WINDIR, "certutil -f -p \"\" -importpfx \"" + sslDir + "\"", WAIT);
if (ret != 0) then return ret; endif;
return 0;
end;
by running Setup.exe as below:
MySetup.exe /v"/l*v c:\SetupLog.log"
I see the below error in log file :
CustomAction ImportSSL returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 16:25:25: ImportSSL. Return value 3.
but when I execute certutil -f -p "" -importpfx "C:\myCertificate.pfx" by command prompt there is no any error , and that certeficate imported into IIS.
How can I know the details of error?
Any help will be truly appreciated.
The problem solution will depend on the following: 1)Is certificate file being delivered by the installer, or is it supposed to be present on the target machine? Check that the installer delivers it as a permanent file, or support file (in [SUPPORTDIR]), or if the file really exists; 2) where this custom action is located? Normally actions like that should be placed after InstallFinalize.

Runtime error with Crystal - "Error opening file"

So I've got the following code causing issues:
if File.file?(indexPath)
puts "Have to move index"
File.rename(indexPath, "#{indexPath}.old")
end
File.new(indexPath)
File.write(indexPath, "test" )#handler.getDoc)
sleep 60.second
I would assume that this would check if the file exists, and back it up before writing a new index.html. Instead, I get the following runtime error:
Error opening file './assets/index.html' with mode 'r': No such file or directory (Errno)
0x10098ab45: *CallStack::unwind:Array(Pointer(Void)) at ??
0x10098aae1: *CallStack#initialize:Array(Pointer(Void)) at ??
0x10098aab8: *CallStack::new:CallStack at ??
0x10097c001: *raise<Errno>:NoReturn at ??
0x1009c9dd9: *File#initialize<String, String, Int32, Nil, Nil>:(Event::Event | Nil) at ??
0x1009cbba9: *File#initialize<String>:(Event::Event | Nil) at ??
0x1009cbb51: *File::new<String>:File at ??
0x10097148b: __crystal_main at ??
0x100981758: main at ??
File.new creates a new instance of the File class, not a new file. Since you give it no further arguments it tries to open the given file in read mode, you just moved it away so that fails.
To create an empty file one would use File.touch, however opening a file in write mode, which File.write internally does, creates the file when it does not exist.
So just removing the call to File.new should work fine.

perl untar single file

So running into an issue with my code here not sure what exactly i'm doing wrong i pass it the two arguments it searches for the file but its always going to does not exist.
i pass this to the file
perl restore.cgi users_old_52715.tar.gz Ace_Walker
its not finding the file it exist i assure you.
#!/usr/bin/perl
use Archive::Tar;
my $tarPath = $ARGV[0];
my $playerfile = $ARGV[1].".ini";
my $tar = Archive::Tar->new($tarPath);
if ($tar->contains_file($playerfile)) {
$tar->read($tarPath);
$tar->extract_file($playerfile, './' );
print "Successfully restored $playerfile to production enviroment\n";
exit 0;
}else{
print $playefile." does not exist in this archive!\n";
exit 0;
}
Just writing Scott Hunter's comment as an answer:
Try using an absolute path instead of a relative one.
if( $tar->extract_file($playerfile, './'.$playerfile )){
print "Successfully restored $playerfile to production enviroment\n";
}
exit 0;
man Archive::Tar :
$tar->extract_file( $file, [$extract_path] )
Write an entry, whose name is equivalent to the file name provided to disk. Optionally takes a second parameter, which is the full native path (including filename) the entry will be written to.

Corrupted Excel File & 7zip

I have a problem with a corrupted excel file. So far I have used 7zip to open it as an archive and extract most of the data. But some important sheets cannot be extracted.
Using the l command of 7zip I get the following output :
7z.exe l -slt "C:\Users\corrupted1.xlsm" xl/worksheets/sheet3.xml
Output:
Listing archive: C:\Users\corrupted1.xlsm
--
Path = C:\Users\corrupted1.xlsm
Type = zip
Physical Size = 11931916
----------
Path = xl\worksheets\sheet3.xml
Folder = -
Size = 57217
Packed Size = 12375
Modified = 1980-01-01 00:00:00
Created =
Accessed =
Attributes = .....
Encrypted = -
Comment =
CRC = 553C3C52
Method = Deflate
Host OS = FAT
Version = 20
However when trying to extract it (or test it for that matter) I get :
7z.exe t -slt "C:\Users\corrupted1.xlsm" xl/worksheets/sheet3.xml
Output:
Processing archive: C:\Users\corrupted1.xlsm
Testing xl\worksheets\sheet3.xml Unsupported Method
Sub items Errors: 1
The method listed above says Deflate, which is the same for all the worksheets.
Is there anything I can do? What kind of corruption is this? Is it the CRC? Can I ignore it somehow or something?
Please help!
Edit:
The following is the error when trying to extract or edit the xml file through 7zip:
Edit 2:
Tried with WinZip as well, getting :
Extracting to "C:\Users\axpavl\AppData\Local\Temp\wzf0b9\"
Use Path: yes Overlay Files: yes
Extracting xl\worksheets\sheet2.xml
Unable to find the local header for xl\worksheets\sheet2.xml.
Severe Error: Cannot find a local header.
This might help:
https://superuser.com/questions/145479/excel-edit-the-xml-inside-an-xlsx-file
and this on too: http://www.techrepublic.com/blog/tr-dojo/recover-data-from-a-damaged-office-file-with-the-help-of-7-zip/

Error while using xlswrite

When I run the following code
function feff
filename = 'UHL DEA.xlsx';
FI = xlsread(filename,'AU9:AU179');
FO = xlsread(filename,'AW9:AW179');
FEff = FI./FO;
%Write the efficiency back to the appropriate file in excel
xlswrite(filename,FEff,'BC9:BC179');
I get the error
Error using xlswrite (line 220)
Excel returned: Error: Object returned error code: 0x800A03EC.
Error in feff (line 15)
xlswrite(filename,FEff,'BC9:BC179');
But it works fine if i write into another file as follows
function feff
filename = 'UHL DEA.xlsx';
FI = xlsread(filename,'AU9:AU179');
FO = xlsread(filename,'AW9:AW179');
FEff = FI./FO;
%Write the efficiency back to the appropriate file in excel
xlswrite('DEA.xlsx',FEff,'BC9:BC179');
The UHL DEA.xlsx contains other data in the previous columns and I need to write this data again in the same file. Pointers will be appreciated. Thanks
Are you using a backward compatible xls file?
HRESULT: 0x800A03EC on Worksheet.range
Check the accepted answer.
Edit: If this is not it, what happens if you try to edit the entire range without using matlab?

Resources