shp2pgsql dumping double fields with comma separator instead of dot - postgis

I guess the source shapefile is the culprit, but is there any way to change to fix it through shp2pgsql?
Obviously Postgres throw an error with:
INSERT INTO "public"."a" ("area","perimeter", ...) VALUES ('5282,98830007762','313,033597376014', ...);
EDIT:
I'm not entirely sure, but I think this is solved if you connect putty from a computer with an English OS

It seems you have a locale that formats floating points with a comma. Try setting the environment variable LC_NUMERIC=C. E.g.:
$ LC_NUMERIC=C shp2pgsql myshp.shp > myshp.sql

In my case it was solved by:
export LANG=en.UTF8
shp2pgsql myshp.shp > myshp.sql

Related

In c printf format of numbers will nor work in mrsh

Using printf format in for numbers which will work fine:
printf ("\r\n <%s>\t AmountOfMalloc %'.ld", HostName ,GetMalloc ()) ;
Output is like this, which is fine:
AmountOfMalloc 17.220.149.424
Calling the same app remote via mrsh in a script will cause no number format like this:
AmountOfMalloc 17220149424
Envirenment is Suse Linux Enterprise Server 15 sp2 in VMware Workstation 15.5.7 on Windows 10 ltsc 2019, 4 cores, 6GB ram.
Has someone expierienced this issue and a possible solution?
The difference is caused by different environment locale settings.
You can see the settings that are applied when the program runs the way you want by running locale command. It will output several lines for e.g. money and number format settings, but usually they all have the same value, such as "en_US.UTF-8".
Easiest way to apply the setting to your remotely run command is to prefix the line like this:
LC_ALL=en_US.UTF-8 /path/to/program
From the examples you provide, the locale you want is probably different than en_US.UTF-8, so use the value you get from locale.
Thanks a lot, locale was the problem. Did not see any reason why,
Adding the following to the c source before printf works fine:
setlocale ( LC_NUMERIC, "de_DE.UTF-8" ) ;
setlocale ( LC_ALL, "de_DE.UTF-8" ) ;
Thanks.

C program exits giving error ORA-12162: TNS:net service name is incorrectly specified

I am working on a remote red-hat server and there I'm developing a c application to insert data in to a remote oracle database. So first i installed the OCI instant client rpm on the server and tried to compile a sample program. after certain linkages I could compile it. But then when I am going to run it. It exits giving an error saying
ORA-12162: TNS:net service name is incorrectly specified
The sample code I used is from the blog (refer to this code in case you need to clarify the things.where I’m quoting only few pieces to this post) René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle
(refer to this code in case you need to clarify the things.where I’m quoting only few pieces to this post)
In the code I added some prints to check for the error And it seems like It gets stuck in the OCIServerAttach() function r gives a printed walue of -1
r=OCIServerAttach(srv, err, dbname, strlen(dbname), (ub4) OCI_DEFAULT);
printf("r value %d",r);
if (r != OCI_SUCCESS) {
checkerr(err, r);
goto clean_up;
}
Another point is that in the compilation process it gives a warning saying that a certain libry is not include. but the exicutable file is created. Here is the massage I get in the compilation process.
[laksithe#loancust ~]$ gcc -L$ORACLE_HOME/lib/ -L$ORACLE_HOME/rdbms/lib/ -o oci_test oci_test.o -L/usr/lib/oracle/12.1/client64/lib -lclntsh `cat $ORACLE_HOME/lib/sysliblist`
cat: /lib/sysliblist: No such file or directory
Going through the web I found that by creating a tnsnames.ora file with the connection details I could solve the problem. But even It didn't work for me. Here is the link for that blog blog
It has been a week since this error and I cold'nt solve it. could someone please help me.
connection string format I used is abc.ghi.com:1521/JKLMN
My recommendation is to bypass tnsnames completely. Oracle has always allowed you to put in the direct connection details, but EZConnect makes that even easier.
When you format your connection string, instead of listing the TNS name, use the actual connection properties in the following format:
servername:port/service name
For Example
MyOracle.MyCompany.Com:1521/SalesReporting
Your connection string might also require direct=true, but I'm honestly not sure.
I like the idea of tnsnames, but it's a double edged sword. When it works, it's great. When it doesn't, you want to throw something. With EZConnect, it always works.
By the way, if you don't know the properties of the three items above, find a machine that connect via tnsnames and:
tnsping <your TNS-named database>

Why won't mariadb listen on port 3306 after a macports update?

At some point after a mariadb port update, she refused to listen on 3306 upon startup.
I made sure there were no skip-networking directives, and even tried adding one with "=OFF", which did nothing... but the odd thing was it had been working, and "I haven't changed anything".
Yet when I run:
/opt/local/lib/mariadb/bin/mysqladmin variables -u root -p | grep skip_networking
I see skip-networking as being ON.
My config has this:
[mysqld]
port = 3306
bind-address = 127.0.0.1
and no skip-networking setting at all.
Even passing the port and bind-address via command line will not make it listen.
After a grep of /opt/local/etc, it turns out there is a default config, and inside that there's a skip-networking directive:
cat /opt/local/etc/mariadb/macports-default.cnf
This was only picked up because after reading /etc/my.cnf, apparently the /opt/local/etc/mariadb/my.cnf file is also read. (I'd used /etc/my.cnf, never having edited the other, but something changed-- maybe I'd edited the default and it was overwritten with the update, though I don't remember doing so.)
Commenting out the include in /opt/local/etc/mariadb/my.cnf of the macports-default.cnf once again has her listening.
Pretty clear solution in retrospect I guess, but I was a bit stumped, as I swear "I changed nothing!"... Regardless-- For posterity, and key word searches!
I can't comment yet, but wanted to add:
If you have other versions of MySQL or mariaDB installed via MacPorts, be sure to check out their config files too because MariaDB reads them.
Locations:
/opt/local/etc/mysql${mysqlVersion}/my.cnf
/opt/local/etc/mariadb-${mariadbVersion}/my.cnf
I have mariadb-10.1-server installed. There are two configs:
/opt/local/etc/mariadb/my.cnf
/opt/local/etc/mariadb-${mariadbVersion}/my.cnf
Additionally, some info about default config files from MirandaDB documentation (this is not Macports specific):
/etc/my.cnf
/etc/mysql/my.cnf
my.cnf in the DEFAULT_SYSCONFDIR specified during the compilation
my.cnf in the path, specified in the environment variable MYSQL_HOME (if any) the file specified in --defaults-extra-file (if any)
user-home-dir/.my.cnf
Alternatively to commenting out the defaults file, the value can be overriden in the my.cnf:
[mysqld]
...
skip_networking=0

Emacs lisp - problems with filename-string on win7

On Win7 with Emacs24 I encounter problems when Emacs programs want to open (pdf) files. The problems remain when I activate or deactivate openwith-mode. I either get a 'wrong-type-argument arrayp nil' message inside Emacs or Acrobat Reader is started but gives an error message 'can't open/find that file'.
I tried to debug it and always ended up in files.el.
It seems that the name of the pdf-file to be opened is constructed by concatenating the absolute filename and the file extension .pdf. However, the filename-string given to AcroRd32 appears to look like this:
AcroRd32 "c:\\absolute\file\name".pdf
This doesn't work on the command line either. I have to change it (manually) to
AcroRd32 "c:\\absolute\file\name.pdf"
or to
AcroRd32 c:\\absolute\file\name.pdf
to make it work.
I don't know if this is considered a bug, or if it is a problem only for me. I tried to change the elisp code to something like
(format "%s" (concat absolute-filename file-extension))
to get rid of those double-quotes, but to no avail. And anyway, I don't feel comfortable to mess around in a basic library like files.el, and its really hard to edebug that library since its invoked permanently.
Maybe somebody encountered the same problem and found a solution?
[I use GNU Emacs 24.0.91.1 (i386-mingw-nt6.1.7601) of 2011-11-22 on MARVIN.]
PS 1 Test Case 1
I get the following error message when I do M-x toggle-debug-on-error and then try to open a pdf file in dired:
Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
file-truename(nil)
find-file-noselect-1(#<buffer test.pdf<4>> "~/.emacs.d/org/projects/sandbox/test.pdf" nil nil "~/.emacs.d/org/projects/sandbox/test.pdf" ((2816 7 . 27468) (16087 . 35227)))
find-file-noselect("c:/Users/tj2/.emacs.d/org/projects/sandbox/test.pdf" nil nil nil)
find-file("c:/Users/tj2/.emacs.d/org/projects/sandbox/test.pdf")
dired-find-file()
call-interactively(dired-find-file nil nil)
and the following message:
Openwith mode enabled
find-file-noselect-1: Wrong type argument: arrayp, nil
Does it matter that my .emacs.d is really a windows symlink (mklink) to a Dropboxfolder?
PS 2 Test Case 2
here is the message I get in the maven-compile buffer, when doing C-c C-s (LilyPond-command-view) in a ,ly buffer:
-*- mode: compilation; default-directory: "~/.emacs.d/org/projects/sandbox/" -*-
Compilation started at Tue Dec 20 09:16:28
AcroRd32 "c:/Users/tj2/.emacs.d/org/projects/sandbox/2test".pdf
Compilation exited abnormally with code 1 at Tue Dec 20 09:16:35
In the message buffer I find
Compilation exited abnormally with code 1
Error during redisplay: (invalid-regexp "Unmatched ( or \\(")
This error doesn't trigger the debugger, although I did M-x toggle-debug-on-error.
Sounds like a bug, to me. Consider reporting it: M-x report-emacs-bug.
Dunno why Michael H. sent you to a Sunrise Commander page with a tip about OpenWith. Perhaps I'm missing something in your question where you indicate that you use one of those packages?
I would suggest reporting an Emacs bug. And if you want to see more about opening Windows apps associated with file types etc. then I'd suggest consulting this page.
This seems to be a problem with openwith.el, so I don't think you'll get much help with an Emacs bug report since openwith.el is not part of Emacs.
I've found a similar error (I'm on Linux) and decided that it would be better to use a "cleaner" alternative that doesn't tweak find-file-noselect (see that page on emacs.sxe for why). The OpenWith wiki page pointed me to a less-popular little bit of glue code,
https://www.emacswiki.org/emacs/download/run-assoc.el (code)
https://www.emacswiki.org/emacs/RunAssoc (docs)
By default this package's run-associated-program is not well-integrated with the usual Emacs workflow, but here is how you can integrate it with helm-find-files (also documented at the above link).
(require 'run-assoc)
(setq associated-program-alist
'(("evince" "\\.pdf$")
("play" "\\.mp3$")))
(defun helm-find-files-maybe-run-assoc (orig-fun &rest args)
(let ((sel (helm-get-selection)))
(if (string-match (mapconcat
(lambda (x) (second x))
associated-program-alist "\\|")
(helm-get-selection))
(run-associated-program sel)
(apply orig-fun args))))
(advice-add 'helm-execute-selection-action
:around #'helm-find-files-maybe-run-assoc)

JVM property -Dfile.encoding=UTF8 or UTF-8?

I would like to know what is the value of the Java Virtual Machine (JVM) property to set my file encoding to UTF-8.
Do I put -Dfile.encoding=UTF8 or -Dfile.encoding=UTF-8?
It will be:
UTF8
See here for the definitions.
If, running an Oracle HotSpot JDK 1.7.x, on a Linux platform where your locale suggests UTF-8 (e.g. LANG=en_US.utf8), if you don't set it on the command-line with -Dfile.encoding, the JDK will default file.encoding and the default Charset like this:
System.out.println(String.format("file.encoding: %s", System.getProperty("file.encoding")));
System.out.println(String.format("defaultCharset: %s", Charset.defaultCharset().name()));
... yields:
file.encoding: UTF-8
defaultCharset: UTF-8
... suggesting the default is UTF-8 on such a platform.
Additionally, if java.nio.charset.Charset.defaultCharset() finds file.encoding not-set, it looks for java.nio.charset.Charset.forName("UTF-8"), suggesting it prefers that string, although it is well-aliased, so "UTF8" will also work fine.
If you run the same program on the same platform with java -Dfile.encoding=UTF8, without the hypen, it yields:
file.encoding: UTF8
defaultCharset: UTF-8
... noting that the default charset has been canonicalized from UTF8 to UTF-8.
Both UTF8 and UTF-8 work for me.
[INFO] BUILD SUCCESS
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
Anyway, it works for me:)
This is not a direct answer, but very useful if you don't have access to how java starts: you can set the environment variable JAVA_TOOLS_OPTIONS to -Dfile.encoding="UTF-8" and every time the jvm starts it will pick up that option.

Resources