How to print out with equal spacing between columns?
For instance, my file contains the following content...
As you can I have to manually control the spacing between the printing of the columns....I think I saw like
Apparently, it isn't working as it printed out
..................
Unless I do like
it will print out like I wanted
Friends,
I have very large data files (File1 and File2).
Search field1 of File1 into Field1 of File2.
If found then do Field1 of File1 MINUS Field1 of File2
if the answer is <= 0.003 (positive or negative) then
print that line from File1.
File1
ABC1231|1.1111|2.2122|3.3133... (3 Replies)
catch signal SIGPIPE ,print errno but it's value equal to 2(ENOENT)
#define ENOENT 2 /* No such file or directory */
is it should be EPIPE ?
#define EPIPE 32 /* Broken pipe */
Thanks ! (7 Replies)
Hi,
I am writing this script to find all files in a directory and print the filepath, date and file size.
However, it doesnt seem to preserve double spacing file with this script. I would appreciate a pointer or 2 to get around this -
printf("%s ",$i) is printing the filepath, what do... (3 Replies)
Hi all
I am trying to scan a file that has 3 columns:
red blue 123351
red blue 848655
red blue 126354
red blue 023158
black white 654896
red blue 650884
I want an output that sums the rows that have matching columns 1 and 2 :wall:
red blue has 5 entries
black white has 1 entry
... (4 Replies)
for (.....)
echo -e "$Name | $Age | $Sex\t|$Grade\t\t"
done
output:
John |12 |Male |6th
Jack |15 |Male |8th
Zachary |15 |Male |9th
I want the lines to line up...but it's out of line when the name is long (2 Replies)
Using awk, print all the lines where field 8 is equal to x
I really did try, but this awk thing is really hard to figure out.
file1.txt"Georgia","Atlanta","2011-11-02","x","","","",""
"California","Los Angeles","2011-11-03","x","","","",""... (2 Replies)
Hi!
I need to change the spacing assigned to each number in a text file. I have an input file with 5 columns and 3 rows. Here, all numbers are separated by 1 space. I need to change this in such a way that the number in the first column has 6, the number in the second column has 5 and all other... (2 Replies)
how to use "awk" to print any record has pattern not equal ? for example my file has 5 records & I need to get all lines which $1=10 or 20 , $2=10 or 20 and $3 greater than "130302" as it shown :
10 20 1303252348212B030
20 10 1303242348212B030
40 34 1303252348212B030
10 20 ... (14 Replies)
I have the code for the below things..
File1 has the content as below
8859 0 subscriberCreate
18 0 subscriberPaymentMethodChange
1650 0 subscriberProfileUpdate
7668 0 subscriberStatusChange
13 4020100 subscriberProfileUpdate
1 4020129 subscriberStatusChange
2 4020307 subscriberCreate
8831... (5 Replies)
Discussion started by: Mahen
5 Replies
LEARN ABOUT PHP
examples-with-pdo_4d
EXAMPLES-WITH-PDO_4D(3) 1 EXAMPLES-WITH-PDO_4D(3)Examples with PDO_4D - Examples PDO_4D
This basic example show how to connect, execute a query, read data and disconnect from a 4D SQL server.
Example #1
Basic example with PDO_4D
<?php
$dsn = '4D:host=localhost;charset=UTF-8';
$user = 'test';
$pass = 'test';
// Connection to the 4D SQL server
$db = new PDO($dsn, $user, $pass);
try {
$db->exec('CREATE TABLE test(id varCHAR(1) NOT NULL, val VARCHAR(10))');
} catch (PDOException $e) {
die("Erreur 4D : " . $e->getMessage());
}
$db->exec("INSERT INTO test VALUES('A', 'B')");
$db->exec("INSERT INTO test VALUES('C', 'D')");
$db->exec("INSERT INTO test VALUES('E', 'F')");
$stmt = $db->prepare('SELECT id, val from test');
$stmt->execute();
print_r($stmt->fetchAll());
unset($stmt);
unset($db);
?>
The above example will output:
Array
(
[0] => Array
(
[ID] => A
[0] => A
[VAL] => B
[1] => B
)
[1] => Array
(
[ID] => C
[0] => C
[VAL] => D
[1] => D
)
[2] => Array
(
[ID] => E
[0] => E
[VAL] => F
[1] => F
)
)
This example shows how to execute a query in 4D language, and how to read the result through PDO_4D.
Example #2
Accessing 4D language from pdo_4d
Set up a 4D method, called method. Make sure in the method properties that the option Available via SQL is checked. The 4D code is
the following.
C_TEXTE($0)
$0:=Version application(*);
The PHP code to use the above 4D method is :
<?php
$dsn = '4D:host=localhost;charset=UTF-8';
$user = 'test';
$pass = 'test';
// Connection to the 4D server
$db = new PDO($dsn, $user, $pass);
$stmt = $db->prepare('SELECT {FN method() AS VARCHAR } FROM _USER_SCHEMAS LIMIT 1');
$stmt->execute();
print_r($stmt->fetchAll());
unset($stmt);
unset($db);
?>
The above example will output:
(
[0] => Array
(
[<expression>] => F0011140
[0] => F0011140
)
)
Example #3
Escaping 4D table names
This examples illustrates how to escape characters in a 4D SQL query.
<?php
$dsn = '4D:host=localhost;charset=UTF-8';
$user = 'test';
$pass = 'test';
// Connection to 4D server 4D
$db = new PDO($dsn, $user, $pass);
$objects = array('[',']','[]','][','[[',']]','[[[',']]]','TBL ]]32[23');
foreach($objects as $id => $object) {
$object = str_replace(']',']]', $object);
print "$object
";
$db->exec('CREATE TABLE IF NOT EXISTS ['.$object.'](['.$object.'] FLOAT)');
$req = "INSERT INTO [$object] ([$object]) VALUES ($id);";
$db->query($req);
$q = $db->prepare("SELECT [$object] FROM [$object]");
$q->execute();
$x[] = $q->fetch(PDO::FETCH_NUM);
$db->exec('DROP TABLE ['.$object.'];');
}
?>
The above example will output:
[
]]
[]]
]][
[[
]]]]
[[[
]]]]]]
TBL ]]]]32[23
PHP Documentation Group EXAMPLES-WITH-PDO_4D(3)