writetofile

How to write numpy arrays to .txt file, starting at a certain line?

有些话、适合烂在心里 提交于 2019-12-10 14:57:15
问题 I need to write 3 numpy arrays into a txt file. The head of the file looks like that: #Filexy #time operation1 operation2 The numpy arrays look like the following: time = np.array([0,60,120,180,...]) operation1 = np.array([12,23,68,26,...)] operation2 = np.array([100,123,203,301,...)] In the end, the .txt file should look like this (delimiter should be a tab): #Filexy #time operation1 operation2 0 12 100 60 23 123 120 68 203 180 26 301 .. ... ... I tried it with "numpy.savetxt" - but I did

Write to a Text File Resource in Android

大憨熊 提交于 2019-12-08 09:30:55
问题 Does anyone know how to write to a text file in Android using a resource like: R.raw.my_text_file I'm just looking for something clean and simple. I've Googled around but the examples I found didn't work. I tried to code using the Android docs but couldn't wrap my head around it... Thanks EDIT: I've used the Android docs to create this code. The logs print out "1" and "9" and the code skips everything in between and does nothing: try { String filename = "res/raw/my_text_file.txt"; String

How to write an observable collection to a txt file?

一曲冷凌霜 提交于 2019-12-08 07:51:24
Whats the best way to write an observable collection to a txt file? I currently have the following public ObservableCollection<Account> SavedActionList = new ObservableCollection<Account>(); using (System.IO.StreamWriter file = new System.IO.StreamWriter("SavedAccounts.txt")) { foreach (Account item in SavedActionList) { file.WriteLine(item.ToString()); //doesn't work } file.Close(); } I'm not sure why it won't write to the file. Any ideas? You can easily just write: File.WriteAllLines("SavedAccounts.txt", SavedActionList.Select(item => item.ToString())); However, this will require your

Android: Writing to a file in AsyncTask

核能气质少年 提交于 2019-12-08 06:26:04
问题 I would love to be able to write to a local directory in my AsyncTask subclass, but I can't seem to figure out how to use getFilesDir(), since I cannot, to my knowledge, create an instance of ContextWrapper and Context in this subclass. So, what have I tried? I've tried getting the files directory the only way I know how by attempting many different things to create instances of Context and ContextWrapper in order to access the getFilesDir() method. That's it. That's all I know how to do. I'm

Android: Writing to a file in AsyncTask

眉间皱痕 提交于 2019-12-06 16:06:48
I would love to be able to write to a local directory in my AsyncTask subclass, but I can't seem to figure out how to use getFilesDir(), since I cannot, to my knowledge, create an instance of ContextWrapper and Context in this subclass. So, what have I tried? I've tried getting the files directory the only way I know how by attempting many different things to create instances of Context and ContextWrapper in order to access the getFilesDir() method. That's it. That's all I know how to do. I'm probably missing a lot of blatantly obvious things, but I've been working with Android for about 2

How to Write data to file in angularJS

冷暖自知 提交于 2019-12-05 13:32:17
I have a variable with huge data some thing like this. $scope.employees = [ {"firstName":"John", "lastName":"Doe", "city": "Bangalore","State":karnataka,}, {"firstName":"Anna", "lastName":"Smith", "city": "Hyderabad","State":AndraPradesh,}, {"firstName":"Peter", "lastName": "Jones", "city": "Mumbai","State":Maharastra,}, ]; I want to save it to JSON file, when I click a button or something. $scope.employees is the object to be saved to a file $scope.savedJSON = angular.toJson($scope.employees,true); var blob = new Blob([$scope.savedJSON],{ type: "application/json;charset=utf-8;" }); var

Batch Script - Ping Address - Write to file if failure

天大地大妈咪最大 提交于 2019-12-04 18:01:14
I want to ping an IP address every 5 seconds. If the ping fails, write the date and time to a file. Here is my non-working attempt... the loop works as intended, but I can't get it to write to a file if the ping fails. @ECHO OFF set IPADDRESS=172.30.1.36 set INTERVAL=5 :PINGINTERVAL ping %IPADDRESS% -n 1 if errorlevel 1 echo %date% %time% >> failurelog.txt timeout %INTERVAL% GOTO PINGINTERVAL In ipv4, ping command only raises errorlevel if there are packets lost. But in you are pinging a machine in your same subnet, you get no packets lost. The easier way to test for ping success is to test

NSFileManager: removing item

血红的双手。 提交于 2019-12-02 18:06:33
问题 The problem is removing an item that´s been written using writeToFile: method, I cannot seem to remove it. I tried NSFileManager but I guess these are two different types of storage. - (BOOL) removeObject: (NSString *)objectToRemove inCategory:(StorageType)category { BOOL result = NO; NSError *removeError; NSString *storageFolder = [self getCategoryFor:category]; if (objectToRemove) { NSFileManager *fileManager = [[NSFileManager alloc]init]; // Find folder NSArray *paths =

How to write a ping to a text file using VBS

余生颓废 提交于 2019-12-02 17:01:25
问题 If I am using VBS to run some CMD commands, in this example ping, how could I write the command to a text file using VBS not DOS? Set objCmdTest = WScript.CreateObject ("WScript.Shell") Set Output = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\vbs\test.txt",8,true) Output.WriteLine (objCmdTest.run ("ping failboat")) Output.WriteLine (objCmdTest.run ("ping 8.8.8.8")) So this is what I'm working with however what happens is; The script runs, the file is made, 2 command prompts

Xcode: directory file for simulator Iphone

喜你入骨 提交于 2019-12-02 14:18:48
i want to write a string in a file "file.txt": this file in my project (for Iphone) is inside Resources; I try to write a string in this file but it don't work, I show my code. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"file.txt"]; NSError *error; [outputString writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:&error]; I want write in this file with simulator xcode, not with device I'm not