Failed to convert excel to pdf using documents4j - documents4j

i'm trying to convert an excel file to pdf using documents4j.
when trying to do so i'm getting the following error:
this is the code i'm running:
can anyone please tell me why do i get the VB exception and how to overcome it?
Thanks.

Your file is in a folder C:\pdf\newPDF.pdf but you are not escaping the second backslash properly. You are instead adding a newline character: \n. You can already tell by the formatting.
Ideally - when I find the time - I will better validate the input at some point.

Related

STG_E_PATHNOTFOUND Error Using RDOMail SaveAs

I am getting error STG_E_PATHNOTFOUND when I try to save certain files to Windows using RDOMail.SaveAs.
I am using the subject of the email as the filename, and, for example, this filename throws the error:-
Viewpoint For Projects™ Transmittal Notification from Emma Hooper on Architectural model upload package (P23) - Advance2, Architectural model upload package, P23, S1-Suitable to 'Share' for Co-ordination, #Y5B2J.msg
All the problem filenames appeared to include ™ so I tried stripping this out but the error persists.
I don't think it is the length of the filename that is causing the problem, and I can create a file in Windows and rename it with any of the problem filenames such as the one above. So the evidence points to a problem in RDOMail converting the text into a filename, rather than a problem with Windows.
Can anyone throw any light on this?
Any assistance will be gratefully received!
Make sure the file name does not include characters invalid in file names, such as ":".

Unquoted carriage return found in data - Preventing COPY FROM in PostgreSQL

I am trying to import a large csv file (~4.5gb) into Postgres but it keeps throwing the following error:
ERROR: unquoted carriage return found in data
HINT: Use quoted CSV field to represent carriage return.
CONTEXT: COPY abc_complete_file_261115, line 9041959
I opened my csv in SublimeText2 and jumped to line 9041959, found the URN for record I needed, loaded the file in Vim and went to that line. I have hidden characters enabled in Vim (by using :set list) so I would expect to see a carriage return ^M somewhere on the line within the data but the only one I could find is at the end of the line as expected.
After an entire day of research and having gotten no further with this issue I ended up deleting the record on line 9041959 - this didn't fix the issue.
Then I figured well maybe it's something strange going on between records - so I ended up deleting about 5 records on either side of the line that threw the error - but it gave the the same error again. (I'll worry about preserving the data later on, right now I'm just trying to import the file so that I can have a look in Postgres). I made sure that I had saved the changes to the csv file before rerunning my query but it just gave the same error.
I feel like I am missing something really really obvious - does anyone have any ideas what might be causing the issue?
I'm using a Mac running El Capitan.
Many thanks
Update 27/11/15
Hi #JakubKania. Sorry for not putting up the query - the reason I didn't was because I am 99.9% sure that the issue is to do with the csv file rather than the query. A generalised version is:
CREATE TABLE large_file_test(
urn VARCHAR,
forename CHAR(32),
surname CHAR(32));
COPY large_file_test FROM '/Users/Shared/largefile1.csv' (FORMAT CSV, DELIMITER ',', HEADER, ENCODING LATIN1);
COPY large_file_test FROM '/Users/Shared/largefile2.csv' (FORMAT CSV, DELIMITER ',', HEADER, ENCODING LATIN1);
COPY large_file_test FROM '/Users/Shared/largefile3.csv' (FORMAT CSV, DELIMITER ',', HEADER, ENCODING LATIN1);
ALTER TABLE large_file_test
ADD CONSTRAINT large_urn
PRIMARY KEY (large_urn);
ANALYZE large_file_test;
So I am actually trying to load 3 separate files into the Table that I created. The issue is that there seems to be hidden characters in part 1 that are preventing it from importing into Postgres. I haven't tried anything with part 2 or 3 yet.
The easiest way I found to solve this in MAC -El Capitan is:
1) Open the file with Sublime Text
2) in menu Reopen the file with encoding UTF8
3) in menu Save the file with encoding UTF8
Sublime "normalize" all end of line EOF.
This likely is caused by Windows line endings. Try installing the utility dos2unix and running dos2unix <filename> before executing the COPY command.
In my case, I noticed that the csv file had an extra blank at the end. After removing it, the file imported properly.
I created a separate folder and gave read/write permissions to "everybody" and that solved all this problem as well as the problem of access being denied when trying to import the file through pgAdmin4 as well. Seems to have been the "cure all".
Now, just to find out which user I need to give these permissions to instead of "everybody".
Using PostgreSQL v 9.6 on Windows 10.

how do I open an image using the python image library?

I am using the image library with python for the first time and am trying to open an image on my pc. So I type in
Image.open(C:\Users\laurence\Google Drive\INB347 web 2.0)
and I keep getting this:
SyntaxError: invalid syntax: with the colon just after the C highlighted in red.
It does not mention this in the handbook which I am following. The example uses
a simpler file location: ('bride.jpg'). How do I open an image file please? thanks.
Try this:
Image.open(r'C:\Users\laurence\Google Drive\INB347 web 2.0')
i.e., enclose your full path in quotes, and put r in front of it to denote is as a 'raw' string, meaning Python won't try to interpret it as anything other than what you put between quotes. You can read more about raw strings here.

Matlab error with "load" - any idea what might cause it?

I'm trying to load a text file into Matlab and getting an error message that doesn't make sense to me. The file is a very large text file containing 8 columns of numbers. The error message says:
Number of columns on line 1308295 of ASCII file [filename.txt] must be the same as previous lines.
But as far as I can see there's nothing special about line 1308295. In fact that line has been in the file for months and the code hasn't complained before. So I wondered if there might be something else unrelated that could cause Matlab to give that error?
What kind of text file is it? If it's a data file, you could try the "importdata" function.

I/O error while reading BCP format file

Today I created a new staging table and a BCP .fmt file. I created some test data and attempted to run the BCP utility from the command line:
I've got about 20 different format files and staging tables from previous work and this is the first time I have encountered this error.
How can I fix this error?
Please note, I have added my solution below, but if you have other answers, please add them in. The answer was so quirky/obscure that I think it may help others.
Basically, this one was really strange. In order for it to work, make sure there is an empty line after the last column defined in the format file. I added an extra empty line, resaved the file, and then the BCP utility ran the file successfully. I've indicated the extra line with a red rectangle.