Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from gautamc/master
adding function to download large files without running out of memory.
- Loading branch information
Showing
3 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Network.FTP.Client | ||
|
||
main :: IO() | ||
main = do | ||
-- connect to SEC's FTP server | ||
(ftp_handle, _) <- connectFTP "ftp.sec.gov" 21 | ||
-- Login as anonymous | ||
login ftp_handle "anonymous" (Just "your.email@someserver.org") Nothing | ||
-- Set transfer mode to binary | ||
sendcmd ftp_handle "TYPE I" | ||
-- Change to the directory where the file is located | ||
cwd ftp_handle "/edgar/data/1251417/" | ||
-- Download the file | ||
downloadlargebinary ftp_handle "0001047469-14-010110.txt" | ||
-- If we tried using downloadbinary then we might see that the program takes up | ||
-- lot of memory and is eventually killed by the haskell runtime | ||
-- downloadbinary ftp_handle "0001047469-14-010110.txt" | ||
return () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters