I have a text file with several thousand numbers arranged like this:
line 1: #0 #1 #2 #3 #4 #5
line 2: #6 #7 #8 #9 #10 #11
...
line 111: #106 #107 #108 #109 #110
line 112: #111 #112 #113 #114 #115
...
What I would like to do is format my file to look like this:
line 1: #0 #1 #2 #3 #4 #5 #111 #112 #113 #114 #115 ...
line 2: #6 #7 #8 #9 #10 #11 #116 #117 #118 #119 #120 #121 ...
...
line 111: #106 #107 #108 #109 #110 #218 #219 #220 #221 #222 #223...
basically I want to arrange my numbers in a 111x111 matrix (so after the first 111 lines which would stay in place line 112 would be merged with the first line, line 113 with the second etc and this would happen for every 111 lines). Is there any way of doing this with awk/sed?
Any help would be appreciated!
If you're ok with having temporary files, you can use split then paste. split splits a file into smaller files of n lines each, and paste takes input files and concatenates them vertically.
Choosing an arbitrary prefix tmp for our temporary files:
split -l 111 input.txt tmp
paste tmp* >output.txt
rm tmp*
Try this, untested since you didn't provide testable sample input/output:
awk -v RS='\\s' '{ORS=(NR%111?"\n":OFS)}1' file
The above uses GNU awk for multi-char RS and \s.
Related
writing a very simple read file in Fortran 95. The file has only three numbers in it, every time I run the code, the .exe file says "error: attempt to read end-of-file at address", any clues why this keeps happening?
The code is :
program readdata
implicit none
!Delcaration of variables
real :: x,y,z
!Main part
open (10, file='C:\Users\matth\OneDrive\Documents\Tutorialcode\array.txt',ACCESS='SEQUENTIAL', STATUS='OLD', FORM='FORMATTED')
read (10, *) x, y, z
print *,x,y,z
close (10)
end program readdata
I have loaded your code into my Eclipse IDE, using GNU Fortran.
I confirm that the code compiles, without error or warning, and runs as advertised.
With an array.txt file of:
1.00, 2.00, 3.00
I get output:
1.00, 2.00, 3.00
With an empty file I get:
At line 13 of file ../readdata.f90 (unit = 10, file = 'C:\Users\franc\array.txt')
Fortran runtime error: End of file
Error termination. Backtrace:
Could not print backtrace: libbacktrace could not find executable to open
#0 0xffffffff
#1 0xffffffff
#2 0xffffffff
#3 0xffffffff
#4 0xffffffff
#5 0xffffffff
#6 0xffffffff
#7 0xffffffff
#8 0xffffffff
#9 0xffffffff
#10 0xffffffff
#11 0xffffffff
#12 0xffffffff
#13 0xffffffff
#14 0xffffffff
So, my suspicion is over whether your file is missing some values.
Please also see:
Fortran 90 - Attempt to read past end of file
When I go to a simple product in order to adjust the price I get a error when I save the product.
Error
There has been an error processing your request
Decoding failed: Syntax error
Trace:
#0 /data/web/public/app/code/core/Mage/Core/Helper/Data.php(659): Zend_Json::decode('', 1)
#1 /data/web/public/app/code/local/Amasty/Conf/Model/Observer.php(145): Mage_Core_Helper_Data->jsonDecode(NULL)
#2 /data/web/public/app/code/core/Mage/Core/Model/App.php(1357): Amasty_Conf_Model_Observer->onSuperProductAttributesPrepareSave(Object(Varien_Event_Observer))
#3 /data/web/public/app/code/core/Mage/Core/Model/App.php(1336): Mage_Core_Model_App->_callObserverMethod(Object(Amasty_Conf_Model_Observer), 'onSuperProductA...', Object(Varien_Event_Observer))
#4 /data/web/public/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('catalog_product...', Array)
#5 /data/web/public/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php(670): Mage::dispatchEvent('catalog_product...', Array)
#6 /data/web/public/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php(725): Mage_Adminhtml_Catalog_ProductController->_initProductSave()
#7 /data/web/public/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Catalog_ProductController->saveAction()
#8 /data/web/public/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('save')
#9 /data/web/public/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#10 /data/web/public/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#11 /data/web/public/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#12 /data/web/public/index.php(83): Mage::run('dutch', 'store')
#13 {main}
Error log record number: 817468762686
I hope someone can tell me what may be the cause.
Best regards,
Michel
Might you be running Magento 1.9 on a PHP7 System? This answer only applies if you are running PHP7. If so, try PHP5.6 and see if it still gives you a problem.
If you are on PHP7, it may be because you need the Inchoo_PHP7 Extension.
Have a look here: https://community.magento.com/t5/Technical-Issues/Magento-1-9-2-create-account-cannot-save-the-customer-error/m-p/42237#M3899
And also here on GitHub, where the extension can also be downloaded: github.com/Inchoo/Inchoo_PHP7/issues/29
I myself had a similar issue on new order creation at http://www.buildersdepot.com, but it seems connected to PHP7, so updating with a new Incho_PHP7 download seems to have done the trick for me on 8/6/2016, my old version was dated around 4/1/2016.
I have followed this step by step instruction to create a table in my database using migrate command but I wondered how it is finalized at the last step. after running "yiic migrate" command I get the following message:
Yii Migration Tool v1.0 (based on Yii v1.1.13)
exception 'CDbException' with message 'CDbConnection.connectionString cannot be
empty.' in D:\wamp\www\news\framework\db\CDbConnection.php:369
Stack trace:
#0 D:\wamp\www\news\framework\db\CDbConnection.php(330): CDbConnection->open()
#1 D:\wamp\www\news\framework\db\CDbConnection.php(308): CDbConnection->setActiv
e(true)
#2 D:\wamp\www\news\framework\base\CModule.php(387): CDbConnection->init()
#3 D:\wamp\www\news\framework\cli\commands\MigrateCommand.php(442): CModule->get
Component('db')
#4 D:\wamp\www\news\framework\cli\commands\MigrateCommand.php(451): MigrateComma
nd->getDbConnection()
#5 D:\wamp\www\news\framework\cli\commands\MigrateCommand.php(482): MigrateComma
nd->getMigrationHistory(-1)
#6 D:\wamp\www\news\framework\cli\commands\MigrateCommand.php(84): MigrateComman
d->getNewMigrations()
#7 [internal function]: MigrateCommand->actionUp(Array)
#8 D:\wamp\www\news\framework\console\CConsoleCommand.php(172): ReflectionMethod
->invokeArgs(Object(MigrateCommand), Array)
#9 D:\wamp\www\news\framework\console\CConsoleCommandRunner.php(67): CConsoleCom
mand->run(Array)
#10 D:\wamp\www\news\framework\console\CConsoleApplication.php(91): CConsoleComm
andRunner->run(Array)
#11 D:\wamp\www\news\framework\base\CApplication.php(169): CConsoleApplication->
processRequest()
#12 D:\wamp\www\news\framework\yiic.php(33): CApplication->run()
#13 D:\wamp\www\news\framework\yiic(14): require_once('D:\wamp\www\new...')
#14 {main}
I don't know what command I have to run after it and how to finish up with the migration process!
Does anybody have a solution on this issue? (I am also using windows 7)
Inside config/console.php add database configuration
'components' => array(
'db'=> array(
'connectionString' => '',
'username' => '',
'password' => '',
)
)
with appropriate database details
You seem to miss the db configuration block in your config/console.php.
gdb /usr/sbin/httpd ./core
(gdb) bt
#0 0x00002af748ff9265 in ?? ()
#1 0x00002af748ffad10 in ?? ()
#2 0x00007fff0a31e248 in ?? ()
#3 0x00007fff0a317aa0 in ?? ()
#4 0x00007fff0a317a10 in ?? ()
#5 0x00007fff0a317ad0 in ?? ()
#6 0x0000000200000000 in ?? ()
plase tell me how to.
thank u.
Your core file comes from an executable built without debugging information. That is why the display of your execution stack lacks function names and lines information
#0 0x00002af748ff9265 in ?? ()
The most likely reason you don't get any symbol names in the core dump is that you either
Have a truncated core, or
Are analyzing core that was produced on a different system from the one you are running GDB on, or
Have a stripped executable (in which case, nm /usr/sbin/httpd will say stripped or something).
My bet it's 1 or 2. If it is 2, see this answer. If it is 3, and you are using system-provided apache build, see if installing httpd-debug or similar package helps.
I have to debug a Cocoa/Objective-C app that has had its symbols stripped. I am pretty well versed in gdb and Objective-C. Normally, I use tools like otool or class-dump to find out what I need to make debugging a little easier. For example, class-dump makes it easy to know where, at runtime, certain methods live.
My question is: Can I "help" gdb provide better symbolic information at runtime when looking at backtraces? In the following backtrace I know (from using class-dump) what all of the methods marked as "??" are. It would be great if I could get gdb to do this for me.
Thanks!
(gdb) bt
#0 0x960de54e in -[NSPersistentUIManager init] ()
#1 0x960de489 in __PersistentUIManager_block_invoke_1 ()
#2 0x9abd0693 in _NSFaultInObject ()
#3 0x960ad800 in +[NSPersistentUIManager sharedManager] ()
#4 0x961aefac in -[NSWindow _doOrderWindow:relativeTo:findKey:forCounter:force:isModal:] ()
#5 0x961aeefd in -[NSWindow orderWindow:relativeTo:] ()
#6 0x96238acc in -[NSWindow orderFront:] ()
#7 0x0000a032 in ?? ()
#8 0x9154bdaa in -[NSObject performSelector:] ()
#9 0x9154bd27 in -[NSSet makeObjectsPerformSelector:] ()
#10 0x960c16a7 in -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] ()
#11 0x960b744d in loadNib ()
#12 0x960b6834 in +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] ()
#13 0x960b673e in +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] ()
#14 0x960b6672 in +[NSBundle(NSNibLoading) loadNibNamed:owner:] ()
#15 0x9633d6c7 in NSApplicationMain ()
#16 0x00002cc6 in ?? ()
#17 0x00002bed in ?? ()
You would need the symbol tables that were generated at the time of the build; typically, the .dSYM folder(s). With those, you can add-symbol-table in GDB and it'll generally figure things out a bit more.
You can't really produce the symbol tables after the fact. Many developers will archive off a copy of the symbol tables for various production releases of their app such that crash traces can be symbolicated and reproducible crashes (that only reproduce on production builds or a particular client install) can be debugged more easily.
The ?? frames are, most likely, C functions for which there are no symbols -- certainly #16 and #17 are _start() and main(). #7 is likely some CF goober used for the -performSelector: internals.
It would be great if I could get gdb to do this for me.
I expect you should be able to. (I haven't done this for Objective-C, only for plain-C, but I can't imagine there will be any difference).
For C, suppose you want to teach GDB that foobar() is at address 0x12345678. Then:
echo 'void foobar() { }' | gcc -c -xc- -o foobar.o
(gdb) add-symbol-file foobar.o 0x12345678
(This works because in relocatable foobar.o the address of foobar() would normally be 0.)